f9552a7818a6eae5e0232cf8df59281e2ffa9ac7
[model-checker-benchmarks.git] / chase-lev-deque-bugfix / testcase5.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         steal(q);
20         steal(q);
21 }
22
23 int user_main(int argc, char **argv)
24 {
25         thrd_t t1, t2;
26         q=create();
27         /** @Entry */
28
29         push(q, 1);
30         push(q, 2);
31         thrd_create(&t1, task, 0);
32         a=take(q);
33         printf("take: a=%d\n", a);
34         thrd_join(t1);
35
36         int d =take(q);
37         bool correct= b == 1 && c == 2 && a == 2 ;
38         MODEL_ASSERT(!correct);
39 /*
40         bool correct=true;
41         if (a!=1 && a!=2 && a!=4 && a!= EMPTY)
42                 correct=false;
43         if (b!=1 && b!=2 && b!=4 && b!= EMPTY)
44                 correct=false;
45         if (c!=1 && c!=2 && c!=4 && a!= EMPTY)
46                 correct=false;
47         if (a!=EMPTY && b!=EMPTY && c!=EMPTY && (a+b+c)!=7)
48                 correct=false;
49         //if (!correct)
50                 printf("a=%d b=%d c=%d\n",a,b,c);
51         MODEL_ASSERT(correct);
52         */
53
54         return 0;
55 }