diff --git a/Makefile b/Makefile index 44cc01c..bff9c1e 100644 --- a/Makefile +++ b/Makefile @@ -180,6 +180,7 @@ UPROGS=\ $U/_bcachetest\ $U/_alloctest\ $U/_specialtest\ + $U/_dhagatest\ # $U/_symlinktest\ fs.img: mkfs/mkfs README user/xargstest.sh $(UPROGS) diff --git a/user/dhagatest.c b/user/dhagatest.c new file mode 100644 index 0000000..3bdd67d --- /dev/null +++ b/user/dhagatest.c @@ -0,0 +1,47 @@ +#include "kernel/types.h" +#include "kernel/stat.h" +#include "user/user.h" + + +void *a = 0x0; + +void +threadFunc() +{ + a = malloc(sizeof(int)); + + if(a == 0x0) + { + printf("\nTest failed due to malloc error"); + exit(1); + } + printf("\nFrom child, modified a to %p", a); +} + +//Stub for testing purposes +/*int create_thread(void (*f)()) +{ + f(); + return 1; +}*/ + +int +main(int argc, char *argv[]) +{ + //int tid = create_thread((void *)&threadFunc); + int tid = create_thread((uint64)&threadFunc); + + if(tid < 0) + { + printf("\nTest failed since thread creation failed"); + exit(1); + } + + while(a == 0x0) + { + continue; + } + + printf("\nMain thread sees the change in vaiable a: %p\n", a); + exit(0); +} \ No newline at end of file