X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=userprog.c;h=33319b1ce873c891b4bce429790196280b3acc12;hb=fe5598b01eb1a72a708a67a1a004149b8bcbc83a;hp=2854ddc4a6b73bdf366b63262ed63ff3c8911eff;hpb=d4253111e600d9e6d1c3469bbc5832d0d79ee89a;p=cdsspec-compiler.git diff --git a/userprog.c b/userprog.c index 2854ddc..33319b1 100644 --- a/userprog.c +++ b/userprog.c @@ -1,4 +1,5 @@ #include +#include #include "libthreads.h" #include "libatomic.h" @@ -30,15 +31,18 @@ static void a(atomic_int *obj) void user_main() { thrd_t t1, t2; - atomic_int obj; + atomic_int *obj; - atomic_init(&obj, 0); + obj = malloc(sizeof(*obj)); + + atomic_init(obj, 0); printf("Thread %d: creating 2 threads\n", thrd_current()); - thrd_create(&t1, (thrd_start_t)&a, &obj); - thrd_create(&t2, (thrd_start_t)&a, &obj); + thrd_create(&t1, (thrd_start_t)&a, obj); + thrd_create(&t2, (thrd_start_t)&a, obj); thrd_join(t1); thrd_join(t2); + free(obj); printf("Thread %d is finished\n", thrd_current()); }