return -1;
}
+bool succ1, succ2;
+
static void main_task(void *param)
{
+
unsigned int val;
int pid = *((int *)param);
+/*
+ if (!pid) {
+ input[0] = 17;
+ succ1 = dequeue(queue, &input[0]);
+ } else {
+ input[1] = 37;
+ enqueue(queue, input[1]);
+ }
+*/
if (!pid) {
input[0] = 17;
- //enqueue(queue, input[0]);
enqueue(queue, input[0]);
- //output[0] = dequeue(queue);
+ succ1 = dequeue(queue, &input[0]);
} else {
input[1] = 37;
- //enqueue(queue, input[1]);
- //output[1] = dequeue(queue);
- //output[0] = dequeue(queue);
- bool succ = dequeue(queue, &output[0]);
+ enqueue(queue, input[1]);
+ succ2 = dequeue(queue, &output[1]);
}
+
}
int user_main(int argc, char **argv)
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 = load_32(&free_lists[t][i]);
+ unsigned int node = free_lists[t][i];
//unsigned int node = free_lists[t][i];
if (node) {
- store_32(&free_lists[t][i], 0);
+ //store_32(&free_lists[t][i], 0);
+ free_lists[t][i] = 0;
//free_lists[t][i] = 0;
return 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 = load_32(&free_lists[t][i]);
+ unsigned int idx = 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);
+ //store_32(&free_lists[t][i], node);
+ free_lists[t][i] = node;
//free_lists[t][i] = node;
return;
}
pointer tmp;
node = new_node();
- store_32(&q->nodes[node].value, val);
+ //store_32(&q->nodes[node].value, val);
+ 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);
while (!success) {
- /**** detected UL ****/
+ /**** detected UL (2 threads, 1 enqueue & 1 dequeue) ****/
tail = atomic_load_explicit(&q->tail, acquire);
/****FIXME: miss ****/
next = atomic_load_explicit(&q->nodes[get_ptr(tail)].next, acquire);
- //printf("miss1_enqueue\n");
if (tail == atomic_load_explicit(&q->tail, relaxed)) {
/* Check for uninitialized 'next' */
if (get_ptr(next) == 0) { // == NULL
pointer value = MAKE_POINTER(node, get_count(next) + 1);
- /**** detected UL ****/
- // Second release can be just relaxed
+ /**** correctness error (1 dequeue & 1 enqueue) ****/
success = atomic_compare_exchange_strong_explicit(&q->nodes[get_ptr(tail)].next,
&next, value, release, relaxed);
/**
}
if (!success) {
// This routine helps the other enqueue to update the tail
- /**** detected UL ****/
+ /**** detected UL (2 threads, 1 enqueue & 1 dequeue) ****/
unsigned int ptr = get_ptr(atomic_load_explicit(&q->nodes[get_ptr(tail)].next, acquire));
pointer value = MAKE_POINTER(ptr,
get_count(tail) + 1);
/****FIXME: miss ****/
- // Second release can be just relaxed
bool succ = false;
succ = atomic_compare_exchange_strong_explicit(&q->tail,
&tail, value, release, relaxed);
}
}
}
- /**** dectected UL ****/
- // Second release can be just relaxed
+ /**** correctness error (1 dequeue & 1 enqueue) ****/
atomic_compare_exchange_strong_explicit(&q->tail,
&tail,
MAKE_POINTER(node, get_count(tail) + 1),
pointer next;
while (!success) {
- /**** detected correctness error ****/
+ /**** FIXME: miss ****/
head = atomic_load_explicit(&q->head, acquire);
- // FIXME: This must be acquire otherwise we have a bug with 1 enqueue &
+ // This must be acquire otherwise we have a bug with 1 enqueue &
// 1 dequeue
- tail = atomic_load_explicit(&q->tail, relaxed);
- /****FIXME: miss ****/
+ /**** correctness error (1 dequeue & 1 enqueue) ****/
+ tail = atomic_load_explicit(&q->tail, acquire);
+ /**** correctness error (1 dequeue & 1 enqueue) ****/
next = atomic_load_explicit(&q->nodes[get_ptr(head)].next, acquire);
//printf("miss3_dequeue\n");
if (atomic_load_explicit(&q->head, relaxed) == head) {
return false; // NULL
}
/****FIXME: miss (not reached) ****/
- // Second release can be just relaxed
bool succ = false;
succ = atomic_compare_exchange_strong_explicit(&q->tail,
&tail,
//printf("miss4_dequeue\n");
thrd_yield();
} else {
- *retVal = load_32(&q->nodes[get_ptr(next)].value);
+ //*retVal = load_32(&q->nodes[get_ptr(next)].value);
+ *retVal = q->nodes[get_ptr(next)].value;
//value = q->nodes[get_ptr(next)].value;
- /****FIXME: correctness error ****/
- // Seconde release can be just relaxed
+ /**** FIXME: miss (not reached) ****/
success = atomic_compare_exchange_strong_explicit(&q->head,
&head,
MAKE_POINTER(get_ptr(next), get_count(head) + 1),