deque: bug fix...method could return empty
[model-checker-benchmarks.git] / chase-lev-deque / main.c
1 #include <stdlib.h>
2 #include <assert.h>
3 #include <stdio.h>
4 #include <threads.h>
5 #include <stdatomic.h>
6
7 #include "deque.h"
8
9 Deque *q;
10 int a;
11 int b;
12
13 static void task(void * param) {
14         a=steal(q);
15 }
16
17 int user_main(int argc, char **argv)
18 {
19         thrd_t t;
20         q=create();
21         thrd_create(&t, task, 0);
22         push(q, 1);
23         push(q, 2);
24         do {
25                 b=take(q);
26         }       while(b==EMPTY);
27         thrd_join(t);
28         if (a+b!=3)
29                 printf("a=%d b=%d\n",a,b);
30         return 0;
31 }