update rcu comments
[model-checker-benchmarks.git] / chase-lev-deque-bugfix / testcase2.c
1 #include <stdlib.h>
2 #include <assert.h>
3 #include <stdio.h>
4 #include <threads.h>
5 #include <stdatomic.h>
6
7 #include "model-assert.h"
8
9 #include "deque.h"
10
11 Deque *q;
12 int a;
13 int b;
14 int c;
15
16 /** Making CAS in steal() (w39) SC */
17
18 static void task(void * param) {
19         b=steal(q);
20         c=steal(q);
21         printf("steal: b=%d, c=%d\n", b, c);
22 }
23
24 int user_main(int argc, char **argv)
25 {
26         thrd_t t1, t2;
27         q=create_size(16);
28         /** @Entry */
29
30         push(q, 1);
31         thrd_create(&t1, task, 0);
32         push(q, 2);
33         a=take(q);
34         printf("take: a=%d\n", a);
35         thrd_join(t1);
36
37         int d =take(q);
38         bool correct= b == 1 && c == 2 && a == 2 ;
39         //MODEL_ASSERT(!correct);
40 /*
41         bool correct=true;
42         if (a!=1 && a!=2 && a!=4 && a!= EMPTY)
43                 correct=false;
44         if (b!=1 && b!=2 && b!=4 && b!= EMPTY)
45                 correct=false;
46         if (c!=1 && c!=2 && c!=4 && a!= EMPTY)
47                 correct=false;
48         if (a!=EMPTY && b!=EMPTY && c!=EMPTY && (a+b+c)!=7)
49                 correct=false;
50         //if (!correct)
51                 printf("a=%d b=%d c=%d\n",a,b,c);
52         MODEL_ASSERT(correct);
53         */
54
55         return 0;
56 }