deque: add test driver, add print messages for now for resize method and if we pull...
authorBrian Demsky <bdemsky@uci.edu>
Thu, 7 Mar 2013 02:58:10 +0000 (18:58 -0800)
committerBrian Demsky <bdemsky@uci.edu>
Thu, 7 Mar 2013 02:58:10 +0000 (18:58 -0800)
test case exposes model checker bugs :(

Makefile
chase-lev-deque/Makefile
chase-lev-deque/deque.c
chase-lev-deque/main.c [new file with mode: 0644]

index f97463a..326c00c 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-DIRS := barrier mcs-lock mpmc-queue spsc-queue spsc-bugfix linuxrwlocks dekker-fences
+DIRS := barrier mcs-lock mpmc-queue spsc-queue spsc-bugfix linuxrwlocks dekker-fences chase-lev-deque
 
 .PHONY: $(DIRS)
 
index 3f0fc86..91ff999 100644 (file)
@@ -2,8 +2,8 @@ include ../benchmarks.mk
 
 TESTNAME = main
 
-HEADERS = 
-OBJECTS = deque.o
+HEADERS = deque.h
+OBJECTS = main.o deque.o
 
 all: $(TESTNAME)
 
index c6631ff..b74907f 100644 (file)
@@ -50,6 +50,7 @@ void resize(Deque *q) {
                atomic_store_explicit(&new_a->buffer[i % new_size], atomic_load_explicit(&a->buffer[i % size], memory_order_relaxed), memory_order_relaxed);
        }
        atomic_store_explicit(&q->array, new_a, memory_order_relaxed);
+       printf("resize\n");
 }
 
 void push(Deque *q, int x) {
diff --git a/chase-lev-deque/main.c b/chase-lev-deque/main.c
new file mode 100644 (file)
index 0000000..64d0444
--- /dev/null
@@ -0,0 +1,29 @@
+#include <stdlib.h>
+#include <assert.h>
+#include <stdio.h>
+#include <threads.h>
+#include <stdatomic.h>
+
+#include "deque.h"
+
+Deque *q;
+int a;
+int b;
+
+static void task(void * param) {
+       a=steal(q);
+}
+
+int user_main(int argc, char **argv)
+{
+       thrd_t t;
+       q=create();
+       thrd_create(&t, task, 0);
+       push(q, 1);
+       push(q, 2);
+       b=take(q);
+       thrd_join(t);
+       if (a+b!=3)
+               printf("a=%d b=%d\n",a,b);
+       return 0;
+}