fe77b178342953450f089ad6536b9d7595d21231
[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 /**
17         Making w39 seq_cst; the two steals and the take have the following:
18         t.CAS() (in steal1)          b.store (in take)
19         fence() (in steal2)              fence() (in take)
20         b.load() (in steal2)         t.load() (in take)
21         neither loads reads the updated value.
22 */
23
24 static void task(void * param) {
25         b=steal(q);
26         c=steal(q);
27 }
28
29 int user_main(int argc, char **argv)
30 {
31         thrd_t t1, t2;
32         q=create_size(4);
33         push(q, 1);
34         push(q, 2);
35         push(q, 3);
36         thrd_create(&t1, task, 0);
37         //thrd_create(&t2, task, 0);
38         a=take(q);
39         //c=take(q);
40         thrd_join(t1);
41         //thrd_join(t2);
42
43 /*
44         bool correct=true;
45         if (a!=1 && a!=2 && a!=4 && a!= EMPTY)
46                 correct=false;
47         if (b!=1 && b!=2 && b!=4 && b!= EMPTY)
48                 correct=false;
49         if (c!=1 && c!=2 && c!=4 && a!= EMPTY)
50                 correct=false;
51         if (a!=EMPTY && b!=EMPTY && c!=EMPTY && (a+b+c)!=7)
52                 correct=false;
53         //if (!correct)
54                 printf("a=%d b=%d c=%d\n",a,b,c);
55         MODEL_ASSERT(correct);
56         */
57
58         return 0;
59 }