From 5180a6fb3697cd85c78bd4d87991f1fc2749172f Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Sun, 20 Mar 2011 22:36:14 -0400 Subject: [PATCH] ck_hp_fifo: Add more fences. Add backoff. --- include/ck_hp_fifo.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/ck_hp_fifo.h b/include/ck_hp_fifo.h index 5006397..a4a1d04 100644 --- a/include/ck_hp_fifo.h +++ b/include/ck_hp_fifo.h @@ -74,6 +74,7 @@ ck_hp_fifo_enqueue_mpmc(ck_hp_record_t *record, void *value) { struct ck_hp_fifo_entry *tail, *next; + ck_backoff_t backoff = CK_BACKOFF_INITIALIZER; entry->value = value; entry->next = NULL; @@ -91,6 +92,8 @@ ck_hp_fifo_enqueue_mpmc(ck_hp_record_t *record, ck_pr_cas_ptr(&fifo->tail, tail, next); else if (ck_pr_cas_ptr(&fifo->tail->next, next, entry) == true) break; + + ck_backoff_eb(&backoff); } ck_pr_cas_ptr(&fifo->tail, tail, entry); @@ -115,6 +118,7 @@ ck_hp_fifo_dequeue_mpmc(ck_hp_record_t *record, next = ck_pr_load_ptr(&head->next); ck_hp_set(record, 1, next); + ck_pr_fence_memory(); if (head != ck_pr_load_ptr(&fifo->head)) continue; @@ -125,6 +129,8 @@ ck_hp_fifo_dequeue_mpmc(ck_hp_record_t *record, ck_pr_cas_ptr(&fifo->tail, tail, next); } else if (ck_pr_cas_ptr(&fifo->head, head, next) == true) break; + + ck_backoff_eb(&backoff); } ck_pr_store_ptr(&value, next->value); @@ -143,5 +149,4 @@ ck_hp_fifo_dequeue_mpmc(ck_hp_record_t *record, (entry) != NULL && ((T) = (entry)->next, 1); \ (entry) = (T)) - #endif /* _CK_HP_FIFO_H */