changes
authorPeizhao Ou <peizhaoo@uci.edu>
Mon, 19 Jan 2015 08:03:14 +0000 (00:03 -0800)
committerPeizhao Ou <peizhaoo@uci.edu>
Mon, 19 Jan 2015 08:03:14 +0000 (00:03 -0800)
benchmark/ms-queue/my_queue.c
benchmark/read-copy-update/rcu.cc

index ad00c0c..a4fcbdb 100644 (file)
@@ -22,11 +22,11 @@ static unsigned int new_node()
        int i;
        int t = get_thread_num();
        for (i = 0; i < MAX_FREELIST; i++) {
-               //unsigned int node = load_32(&free_lists[t][i]);
-               unsigned int node = free_lists[t][i];
+               unsigned int node = load_32(&free_lists[t][i]);
+               //unsigned int node = free_lists[t][i];
                if (node) {
-                       //store_32(&free_lists[t][i], 0);
-                       free_lists[t][i] = 0;
+                       store_32(&free_lists[t][i], 0);
+                       //free_lists[t][i] = 0;
                        return node;
                }
        }
@@ -46,13 +46,13 @@ static void reclaim(unsigned int node)
 
        for (i = 0; i < MAX_FREELIST; i++) {
                /* Should never race with our own thread here */
-               //unsigned int idx = load_32(&free_lists[t][i]);
-               unsigned int idx = free_lists[t][i];
+               unsigned int idx = load_32(&free_lists[t][i]);
+               //unsigned int idx = free_lists[t][i];
 
                /* Found empty spot in free list */
                if (idx == 0) {
-                       //store_32(&free_lists[t][i], node);
-                       free_lists[t][i] = node;
+                       store_32(&free_lists[t][i], node);
+                       //free_lists[t][i] = node;
                        return;
                }
        }
@@ -97,8 +97,8 @@ void enqueue(queue_t *q, unsigned int val)
        pointer tmp;
 
        node = new_node();
-       //store_32(&q->nodes[node].value, val);
-       q->nodes[node].value = val;
+       store_32(&q->nodes[node].value, val);
+       //q->nodes[node].value = val;
        tmp = atomic_load_explicit(&q->nodes[node].next, relaxed);
        set_ptr(&tmp, 0); // NULL
        atomic_store_explicit(&q->nodes[node].next, tmp, relaxed);
@@ -201,9 +201,9 @@ bool dequeue(queue_t *q, int *retVal)
                        @Label: Dequeue_Read_Head
                        @End
                */
-               /** FIXME: A new bug has been found here!!! It should be acquire instead of
+               /** A new bug has been found here!!! It should be acquire instead of
                 * relaxed (it introduces a bug when there's two dequeuers and one
-                * enqueuer)
+                * enqueuer) correctness bug!!
                 */
                tail = atomic_load_explicit(&q->tail, acquire);
                /**
@@ -251,9 +251,9 @@ bool dequeue(queue_t *q, int *retVal)
                                //printf("miss4_dequeue\n");
                                thrd_yield();
                        } else {
-                               //value = load_32(&q->nodes[get_ptr(next)].value);
-                               value = q->nodes[get_ptr(next)].value;
-                               /****FIXME: correctness error ****/
+                               value = load_32(&q->nodes[get_ptr(next)].value);
+                               //value = q->nodes[get_ptr(next)].value;
+                               /**** correctness error ****/
                                success = atomic_compare_exchange_strong_explicit(&q->head,
                                                &head,
                                                MAKE_POINTER(get_ptr(next), get_count(head) + 1),
index e0edc4e..b665480 100644 (file)
@@ -80,8 +80,8 @@ Data* read() {
 Data* write(int d1, int d2, int d3) {
        bool succ = false;
        Data *tmp = (Data*) malloc(sizeof(Data));
+       Data *prev = data.load(memory_order_acquire);
        do {
-               Data *prev = data.load(memory_order_acquire);
         //store_32(&tmp->data1, prev->data1 + d1);
         tmp->data1 = prev->data1 + d1;
            tmp->data2 = prev->data2 + d2;