litmus: seq-lock: add MODEL_ASSERT() for the important behavior
[c11tester.git] / test / litmus / store-buffer.cc
1 #include <stdio.h>
2 #include <threads.h>
3 #include <atomic>
4
5 std::atomic_int x;
6 std::atomic_int y;
7
8 static void a(void *obj)
9 {
10         x.store(1, std::memory_order_relaxed);
11         printf("y: %d\n", y.load(std::memory_order_relaxed));
12 }
13
14 static void b(void *obj)
15 {
16         y.store(1, std::memory_order_relaxed);
17         printf("x: %d\n", x.load(std::memory_order_relaxed));
18 }
19
20 int user_main(int argc, char **argv)
21 {
22         thrd_t t1, t2;
23
24         atomic_init(&x, 0);
25         atomic_init(&y, 0);
26
27         printf("Main thread: creating 2 threads\n");
28         thrd_create(&t1, (thrd_start_t)&a, NULL);
29         thrd_create(&t2, (thrd_start_t)&b, NULL);
30
31         thrd_join(t1);
32         thrd_join(t2);
33         printf("Main thread is finished\n");
34
35         return 0;
36 }