X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=test%2Freleaseseq.c;h=548f0a822380ae19640cb30197d7ac6e1209fde4;hb=2d0d4ac38e05905a6633b3f2d5112ccadd45c27f;hp=d3127f392206be6609fd20476a11ad730cfcb7d2;hpb=c27cd2246700b671d0efb1cafd8bbc1ef2c90535;p=model-checker.git diff --git a/test/releaseseq.c b/test/releaseseq.c index d3127f3..548f0a8 100644 --- a/test/releaseseq.c +++ b/test/releaseseq.c @@ -5,15 +5,17 @@ */ #include +#include +#include -#include "libthreads.h" #include "librace.h" -#include "stdatomic.h" atomic_int x; +int var = 0; static void a(void *obj) { + store_32(&var, 1); atomic_store_explicit(&x, 1, memory_order_release); atomic_store_explicit(&x, 42, memory_order_relaxed); } @@ -21,7 +23,8 @@ static void a(void *obj) static void b(void *obj) { int r = atomic_load_explicit(&x, memory_order_acquire); - printf("r = %u\n", r); + printf("r = %d\n", r); + printf("load %d\n", load_32(&var)); } static void c(void *obj) @@ -29,13 +32,13 @@ static void c(void *obj) atomic_store_explicit(&x, 2, memory_order_relaxed); } -void user_main() +int user_main(int argc, char **argv) { thrd_t t1, t2, t3; atomic_init(&x, 0); - printf("Thread %d: creating 3 threads\n", thrd_current()); + printf("Main thread: creating 3 threads\n"); thrd_create(&t1, (thrd_start_t)&a, NULL); thrd_create(&t2, (thrd_start_t)&b, NULL); thrd_create(&t3, (thrd_start_t)&c, NULL); @@ -43,5 +46,7 @@ void user_main() thrd_join(t1); thrd_join(t2); thrd_join(t3); - printf("Thread %d is finished\n", thrd_current()); + printf("Main thread is finished\n"); + + return 0; }