model: schedule appropriate fence backtracking points
[c11tester.git] / test / rmwprog.c
1 #include <stdlib.h>
2 #include <stdio.h>
3 #include <threads.h>
4 #include <stdatomic.h>
5
6 #include "librace.h"
7
8 atomic_int x;
9 static int N = 2;
10
11 static void a(void *obj)
12 {
13         int i;
14         for (i = 0; i < N; i++)
15                 atomic_fetch_add_explicit(&x, 1, memory_order_relaxed);
16 }
17
18 int user_main(int argc, char **argv)
19 {
20         thrd_t t1, t2;
21
22         if (argc > 1)
23                 N = atoi(argv[1]);
24
25         atomic_init(&x, 0);
26         thrd_create(&t1, (thrd_start_t)&a, NULL);
27         thrd_create(&t2, (thrd_start_t)&a, NULL);
28
29         thrd_join(t1);
30         thrd_join(t2);
31
32         return 0;
33 }