update rcu comments
[model-checker-benchmarks.git] / ticket-lock / testcase1.c
1 #include <threads.h>
2 #include <stdatomic.h>
3
4 #include "librace.h"
5 #include "lock.h" 
6
7 TicketLock mylock;
8 int shareddata;
9
10 static void a(void *obj)
11 {
12         int i;
13         for(i = 0; i < 2; i++) {
14                 if ((i % 2) == 0) {
15                         lock(&mylock);
16                         //load_32(&shareddata);
17                         unlock(&mylock);
18                 } else {
19                         lock(&mylock);
20                         //store_32(&shareddata,(unsigned int)i);
21                         unlock(&mylock);
22                 }
23         }
24 }
25
26 int user_main(int argc, char **argv)
27 {
28         thrd_t t1, t2;
29         /** @Entry */
30         initTicketLock(&mylock);
31
32         thrd_create(&t1, (thrd_start_t)&a, NULL);
33         thrd_create(&t2, (thrd_start_t)&a, NULL);
34
35         thrd_join(t1);
36         thrd_join(t2);
37
38         return 0;
39 }