X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=ms-queue%2Ftestcase3.c;h=628574ec9fdba4fbf653a5e57f912eed537f26d0;hb=357cc2d31eaf9df96c2fc676fa00f40a54e83019;hp=f6243f999abf5e807e545130132ad21445c1aa71;hpb=e4f5d19cd0d94393277381f8aab95126f201fb26;p=model-checker-benchmarks.git diff --git a/ms-queue/testcase3.c b/ms-queue/testcase3.c index f6243f9..628574e 100644 --- a/ms-queue/testcase3.c +++ b/ms-queue/testcase3.c @@ -25,28 +25,33 @@ int get_thread_num() bool succ1, succ2; atomic_int x[3]; int idx1, idx2; +unsigned int reclaimNode1, reclaimNode2; + +static int procs = 2; + + +/** This testcase can infer w2->release & w4->acquire. + The initial node that Head and Tail points to is 1, so when T3 enqueue with + node 2, and dequeue(get node 1), and enqueue node 1 again, the second time + it enqueues node 1 it actually first initialize node1->next. At the same + time in T2, it reads that node1->next (because it reads the old Tail at the + very beginning), then loads the Tail agian (w4), it can actully reads an old + value. And this is a bug because if node 1 is again dequeued, then for T2 to + update node1->next, it can potentially contaminate the memory... +*/ -static int procs = 4; static void main_task(void *param) { unsigned int val; int pid = *((int *)param); if (pid % 4 == 0) { - atomic_store_explicit(&x[0], 1, memory_order_relaxed); - enqueue(queue, 0); - - succ1 = dequeue(queue, &idx1); - if (succ1) { - atomic_load_explicit(&x[idx1], memory_order_relaxed); - } + enqueue(queue, 0, 3); } else if (pid % 4 == 1) { - atomic_store_explicit(&x[1], 1, memory_order_relaxed); - enqueue(queue, 1); - - succ2 = dequeue(queue, &idx2); - if (succ2) { - atomic_load_explicit(&x[idx2], memory_order_relaxed); - } + enqueue(queue, 1, 2); + succ1 = dequeue(queue, &idx1, &reclaimNode1); + enqueue(queue, 1, 1); + //succ1 = dequeue(queue, &idx1, &reclaimNode1); + //enqueue(queue, 1, false, 2); } else if (pid % 4 == 2) { } else if (pid % 4 == 3) {