Created
August 25, 2020 19:34
-
-
Save edwintorok/139ed75a283e3e6bbab59ebfd033ccbe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -rwu chase-lev-deque/deque.c chase-lev-deque-bugfix/deque.c | |
--- chase-lev-deque/deque.c 2020-08-25 20:29:46.964661118 +0100 | |
+++ chase-lev-deque-bugfix/deque.c 2020-08-25 20:29:46.963661116 +0100 | |
@@ -50,7 +50,7 @@ | |
for(i=top; i < bottom; i++) { | |
atomic_store_explicit(&new_a->buffer[i % new_size], atomic_load_explicit(&a->buffer[i % size], memory_order_relaxed), memory_order_relaxed); | |
} | |
- atomic_store_explicit(&q->array, new_a, memory_order_relaxed); | |
+ atomic_store_explicit(&q->array, new_a, memory_order_release); | |
printf("resize\n"); | |
} | |
@@ -75,7 +75,7 @@ | |
int x = EMPTY; | |
if (t < b) { | |
/* Non-empty queue. */ | |
- Array *a = (Array *) atomic_load_explicit(&q->array, memory_order_relaxed); | |
+ Array *a = (Array *) atomic_load_explicit(&q->array, memory_order_acquire); | |
x = atomic_load_explicit(&a->buffer[t % atomic_load_explicit(&a->size, memory_order_relaxed)], memory_order_relaxed); | |
if (!atomic_compare_exchange_strong_explicit(&q->top, &t, t + 1, memory_order_seq_cst, memory_order_relaxed)) | |
/* Failed race. */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment