c3a5ea82fb328b793b967707b2a2c3ec2cb38990
[model-checker.git] / test / rmwprog.c
1 #include <stdio.h>
2
3 #include "libthreads.h"
4 #include "librace.h"
5 #include "stdatomic.h"
6
7 atomic_int x;
8
9 static void a(void *obj)
10 {
11         atomic_fetch_add_explicit(&x, 1, memory_order_relaxed);
12         atomic_fetch_add_explicit(&x, 1, memory_order_relaxed);
13 }
14
15 void user_main()
16 {
17         thrd_t t1, t2;
18
19         atomic_init(&x, 0);
20         thrd_create(&t1, (thrd_start_t)&a, NULL);
21         thrd_create(&t2, (thrd_start_t)&a, NULL);
22
23         thrd_join(t1);
24         thrd_join(t2);
25 }