tests: add some normal loads/stores to test data races
authorBrian Norris <banorris@uci.edu>
Mon, 8 Oct 2012 05:19:01 +0000 (22:19 -0700)
committerBrian Norris <banorris@uci.edu>
Mon, 8 Oct 2012 05:22:52 +0000 (22:22 -0700)
These tests had become less useful, since the model-checker would ignore
release sequence fixup in the absence of pending data races. So add some
normal loads and stores to our tests, inducing some data races and some
proper synchronization.

test/pending-release.c
test/releaseseq.c

index 37433b150fb5ed7163d31d69aaf3876997cf37c9..f3ae9f43420b2cdc5de5e8cf59cf4c72921ecba9 100644 (file)
 #include "stdatomic.h"
 
 atomic_int x;
+int var = 0;
 
 static void a(void *obj)
 {
+       store_32(&var, 1);
        atomic_store_explicit(&x, *((int *)obj), memory_order_release);
        atomic_store_explicit(&x, *((int *)obj) + 1, memory_order_relaxed);
 }
@@ -23,6 +25,7 @@ static void b2(void *obj)
 {
        int r = atomic_load_explicit(&x, memory_order_acquire);
        printf("r = %u\n", r);
+       store_32(&var, 3);
 }
 
 static void b1(void *obj)
@@ -31,6 +34,7 @@ static void b1(void *obj)
        int i = 7;
        int r = atomic_load_explicit(&x, memory_order_acquire);
        printf("r = %u\n", r);
+       store_32(&var, 2);
        thrd_create(&t3, (thrd_start_t)&a, &i);
        thrd_create(&t4, (thrd_start_t)&b2, NULL);
        thrd_join(t3);
index d3127f392206be6609fd20476a11ad730cfcb7d2..462a59f32a30251de82bed4ffbe451b8b862ed0b 100644 (file)
 #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);
 }
@@ -22,6 +24,7 @@ static void b(void *obj)
 {
        int r = atomic_load_explicit(&x, memory_order_acquire);
        printf("r = %u\n", r);
+       printf("load %d\n", load_32(&var));
 }
 
 static void c(void *obj)