2 * This test performs some relaxes, release, acquire opeations on a single
3 * atomic variable. It is designed for creating a difficult set of pending
4 * release sequences to resolve at the end of an execution. However, it
5 * utilizes 6 threads, so it blows up into a lot of executions quickly.
10 #include "libthreads.h"
12 #include "stdatomic.h"
16 static void a(void *obj)
18 atomic_store_explicit(&x, *((int *)obj), memory_order_release);
19 atomic_store_explicit(&x, *((int *)obj) + 1, memory_order_relaxed);
22 static void b2(void *obj)
24 int r = atomic_load_explicit(&x, memory_order_acquire);
25 printf("r = %u\n", r);
28 static void b1(void *obj)
32 int r = atomic_load_explicit(&x, memory_order_acquire);
33 printf("r = %u\n", r);
34 thrd_create(&t3, (thrd_start_t)&a, &i);
35 thrd_create(&t4, (thrd_start_t)&b2, NULL);
40 static void c(void *obj)
42 atomic_store_explicit(&x, 22, memory_order_relaxed);
52 thrd_create(&t1, (thrd_start_t)&a, &i);
53 thrd_create(&t2, (thrd_start_t)&b1, NULL);
54 thrd_create(&t5, (thrd_start_t)&c, NULL);