From: Brian Norris Date: Thu, 31 May 2012 02:42:07 +0000 (-0700) Subject: userprog: use atomics allocated on "heap" X-Git-Tag: pldi2013~391^2~54 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=1a0114ccaf1f6a8dc1656589c6d733354fe310cd;p=model-checker.git userprog: use atomics allocated on "heap" Just for kicks, since snapshotting is working properly. We might as well test this. --- 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()); }