7d60fd5dafc21c130a957fd777260fa34c072c45
[model-checker-benchmarks.git] / chase-lev-deque-bugfix / testcase1.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 atomic_int x[2];
17
18 /**
19         Synchronization between plain push and steal
20 */
21
22 static void task(void * param) {
23         a=steal(q);
24         printf("a=%d\n", a);
25         if (a != EMPTY && a != ABORT)
26                 atomic_load_explicit(&x[a], memory_order_relaxed);
27 }
28
29 int user_main(int argc, char **argv)
30 {
31         thrd_t t;
32         atomic_store_explicit(&x[0], 0,  memory_order_relaxed);
33         atomic_store_explicit(&x[1], 0,  memory_order_relaxed);
34         q=create_size(4);
35         thrd_create(&t, task, 0);
36         //atomic_store_explicit(&x[1], 37,  memory_order_relaxed);
37         push(q, 1);
38         //push(q, 4);
39         //b=take(q);
40         //c=take(q);
41         thrd_join(t);
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 }