ck_hp_fifo: Add more fences. Add backoff.

ck_pring
Samy Al Bahra 14 years ago
parent beafb7d78e
commit 5180a6fb36

@ -74,6 +74,7 @@ ck_hp_fifo_enqueue_mpmc(ck_hp_record_t *record,
void *value) void *value)
{ {
struct ck_hp_fifo_entry *tail, *next; struct ck_hp_fifo_entry *tail, *next;
ck_backoff_t backoff = CK_BACKOFF_INITIALIZER;
entry->value = value; entry->value = value;
entry->next = NULL; 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); ck_pr_cas_ptr(&fifo->tail, tail, next);
else if (ck_pr_cas_ptr(&fifo->tail->next, next, entry) == true) else if (ck_pr_cas_ptr(&fifo->tail->next, next, entry) == true)
break; break;
ck_backoff_eb(&backoff);
} }
ck_pr_cas_ptr(&fifo->tail, tail, entry); 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); next = ck_pr_load_ptr(&head->next);
ck_hp_set(record, 1, next); ck_hp_set(record, 1, next);
ck_pr_fence_memory();
if (head != ck_pr_load_ptr(&fifo->head)) if (head != ck_pr_load_ptr(&fifo->head))
continue; continue;
@ -125,6 +129,8 @@ ck_hp_fifo_dequeue_mpmc(ck_hp_record_t *record,
ck_pr_cas_ptr(&fifo->tail, tail, next); ck_pr_cas_ptr(&fifo->tail, tail, next);
} else if (ck_pr_cas_ptr(&fifo->head, head, next) == true) } else if (ck_pr_cas_ptr(&fifo->head, head, next) == true)
break; break;
ck_backoff_eb(&backoff);
} }
ck_pr_store_ptr(&value, next->value); 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) != NULL && ((T) = (entry)->next, 1); \
(entry) = (T)) (entry) = (T))
#endif /* _CK_HP_FIFO_H */ #endif /* _CK_HP_FIFO_H */

Loading…
Cancel
Save