projects
/
model-checker-benchmarks.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
688f4bd
)
ms-queue: relax the second load of head/tail
author
Brian Norris
<banorris@uci.edu>
Fri, 8 Mar 2013 02:09:18 +0000
(18:09 -0800)
committer
Brian Norris
<banorris@uci.edu>
Fri, 8 Mar 2013 02:09:18 +0000
(18:09 -0800)
ms-queue/my_queue.c
patch
|
blob
|
history
diff --git
a/ms-queue/my_queue.c
b/ms-queue/my_queue.c
index
efab237
..
d658407
100644
(file)
--- a/
ms-queue/my_queue.c
+++ b/
ms-queue/my_queue.c
@@
-70,7
+70,7
@@
void enqueue(queue_t *q, unsigned int val)
while (!success) {
tail = atomic_load_explicit(&q->tail, acquire);
next = atomic_load_explicit(&q->nodes[get_ptr(tail)].next, acquire);
while (!success) {
tail = atomic_load_explicit(&q->tail, acquire);
next = atomic_load_explicit(&q->nodes[get_ptr(tail)].next, acquire);
- if (tail == atomic_load_explicit(&q->tail,
acquire
)) {
+ if (tail == atomic_load_explicit(&q->tail,
relaxed
)) {
if (get_ptr(next) == 0) { // == NULL
pointer value = MAKE_POINTER(node, get_count(next) + 1);
success = atomic_compare_exchange_strong_explicit(&q->nodes[get_ptr(tail)].next,
if (get_ptr(next) == 0) { // == NULL
pointer value = MAKE_POINTER(node, get_count(next) + 1);
success = atomic_compare_exchange_strong_explicit(&q->nodes[get_ptr(tail)].next,
@@
-105,7
+105,7
@@
unsigned int dequeue(queue_t *q)
head = atomic_load_explicit(&q->head, acquire);
tail = atomic_load_explicit(&q->tail, acquire);
next = atomic_load_explicit(&q->nodes[get_ptr(head)].next, acquire);
head = atomic_load_explicit(&q->head, acquire);
tail = atomic_load_explicit(&q->tail, acquire);
next = atomic_load_explicit(&q->nodes[get_ptr(head)].next, acquire);
- if (atomic_load_explicit(&q->head,
acquire
) == head) {
+ if (atomic_load_explicit(&q->head,
relaxed
) == head) {
if (get_ptr(head) == get_ptr(tail)) {
if (get_ptr(next) == 0) { // NULL
return 0; // NULL
if (get_ptr(head) == get_ptr(tail)) {
if (get_ptr(next) == 0) { // NULL
return 0; // NULL