Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ UPROGS=\
$U/_bcachetest\
$U/_alloctest\
$U/_specialtest\
$U/_dhagatest\
# $U/_symlinktest\

fs.img: mkfs/mkfs README user/xargstest.sh $(UPROGS)
Expand Down
47 changes: 47 additions & 0 deletions user/dhagatest.c
Original file line number Diff line number Diff line change
@@ -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);
}