The CDSSpec checker's benchmarks
[model-checker-benchmarks.git] / read-copy-update / main.cc
1 #include <threads.h>
2 #include "rcu.h"
3
4 void threadA(void *arg) {
5         write(1, 0);
6 }
7
8 void threadB(void *arg) {
9         write(0, 2);
10 }
11
12 void threadC(void *arg) {
13         write(2, 2);
14 }
15
16 void threadD(void *arg) {
17         int *d1 = new int;
18         int *d2 = new int;
19         read(d1, d2);
20         printf("ThreadD: d1=%d, d2=%d\n", *d1, *d2);
21 }
22
23 int user_main(int argc, char **argv) {
24         thrd_t t1, t2, t3, t4;
25         /** @Entry */
26         Data *dataInit = new Data;
27         dataInit->data1 = 0;
28         dataInit->data2 = 0;
29         atomic_init(&dataPtr, dataInit);
30
31         thrd_create(&t1, threadA, NULL);
32         thrd_create(&t2, threadB, NULL);
33         //thrd_create(&t3, threadC, NULL);
34         thrd_create(&t4, threadD, NULL);
35
36         thrd_join(t1);
37         thrd_join(t2);
38         //thrd_join(t3);
39         thrd_join(t4);
40
41         return 0;
42 }