projects
/
model-checker-benchmarks.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
ms-queue: cleanups
[model-checker-benchmarks.git]
/
ms-queue
/
my_queue.c
diff --git
a/ms-queue/my_queue.c
b/ms-queue/my_queue.c
index 9ffb343dd3174ec970da9685c2e203ad1c38f242..33a62925c7a6a195fc0002cd54b2d3ce8807553a 100644
(file)
--- a/
ms-queue/my_queue.c
+++ b/
ms-queue/my_queue.c
@@
-66,18
+66,16
@@
void enqueue(queue_t *q, unsigned int val)
next = atomic_load(&q->nodes[get_ptr(tail)].next);
if (tail == atomic_load(&q->tail)) {
if (get_ptr(next) == 0) { // == NULL
next = atomic_load(&q->nodes[get_ptr(tail)].next);
if (tail == atomic_load(&q->tail)) {
if (get_ptr(next) == 0) { // == NULL
- pointer val = MAKE_POINTER(node, get_count(next) + 1);
+ pointer val
ue
= MAKE_POINTER(node, get_count(next) + 1);
success = atomic_compare_exchange_weak(&q->nodes[get_ptr(tail)].next,
success = atomic_compare_exchange_weak(&q->nodes[get_ptr(tail)].next,
- &next,
- val);
+ &next, value);
}
if (!success) {
unsigned int ptr = get_ptr(atomic_load(&q->nodes[get_ptr(tail)].next));
}
if (!success) {
unsigned int ptr = get_ptr(atomic_load(&q->nodes[get_ptr(tail)].next));
- pointer val = MAKE_POINTER(ptr,
+ pointer val
ue
= MAKE_POINTER(ptr,
get_count(tail) + 1);
atomic_compare_exchange_strong(&q->tail,
get_count(tail) + 1);
atomic_compare_exchange_strong(&q->tail,
- &tail,
- val);
+ &tail, value);
thrd_yield();
}
}
thrd_yield();
}
}
@@
-104,7
+102,7
@@
unsigned int dequeue(queue_t *q)
if (get_ptr(next) == 0) { // NULL
return 0; // NULL
}
if (get_ptr(next) == 0) { // NULL
return 0; // NULL
}
- atomic_compare_exchange_
weak
(&q->tail,
+ atomic_compare_exchange_
strong
(&q->tail,
&tail,
MAKE_POINTER(get_ptr(next), get_count(tail) + 1));
thrd_yield();
&tail,
MAKE_POINTER(get_ptr(next), get_count(tail) + 1));
thrd_yield();