changes
[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 (making w31 release and w35
20         acquire)
21 */
22
23 static void task(void * param) {
24         a=steal(q);
25         printf("a=%d\n", a);
26         if (a != EMPTY && a != ABORT)
27                 atomic_load_explicit(&x[a], memory_order_relaxed);
28 }
29
30 int user_main(int argc, char **argv)
31 {
32         thrd_t t;
33         atomic_store_explicit(&x[0], 0,  memory_order_relaxed);
34         atomic_store_explicit(&x[1], 0,  memory_order_relaxed);
35         q=create_size(4);
36         thrd_create(&t, task, 0);
37         //atomic_store_explicit(&x[1], 37,  memory_order_relaxed);
38         push(q, 1);
39         //push(q, 4);
40         //b=take(q);
41         //c=take(q);
42         thrd_join(t);
43
44 /*
45         bool correct=true;
46         if (a!=1 && a!=2 && a!=4 && a!= EMPTY)
47                 correct=false;
48         if (b!=1 && b!=2 && b!=4 && b!= EMPTY)
49                 correct=false;
50         if (c!=1 && c!=2 && c!=4 && a!= EMPTY)
51                 correct=false;
52         if (a!=EMPTY && b!=EMPTY && c!=EMPTY && (a+b+c)!=7)
53                 correct=false;
54         //if (!correct)
55                 printf("a=%d b=%d c=%d\n",a,b,c);
56         MODEL_ASSERT(correct);
57         */
58
59         return 0;
60 }