add top-level Makefile
[model-checker-benchmarks.git] / barrier / barrier.cc
1 #include <stdio.h>
2 #include <threads.h>
3
4 #include "barrier.h"
5
6 #include "librace.h"
7
8 spinning_barrier *barr;
9 int var = 0;
10
11 void threadA(void *arg)
12 {
13         store_32(&var, 1);
14         barr->wait();
15 }
16
17 void threadB(void *arg)
18 {
19         barr->wait();
20         printf("var = %d\n", load_32(&var));
21 }
22
23 int user_main(int argc, char **argv)
24 {
25         thrd_t t2, t3;
26
27         barr = new spinning_barrier(2);
28
29         thrd_create(&t2, &threadA, NULL);
30         thrd_create(&t3, &threadB, NULL);
31         thrd_join(t2);
32         thrd_join(t3);
33
34         return 0;
35 }