ck_fifo: Add fences to ABA-friendly operations.

ck_pring
Samy Al Bahra 10 years ago
parent f95c2c2413
commit 851098b552

@ -262,6 +262,7 @@ ck_fifo_mpmc_enqueue(struct ck_fifo_mpmc *fifo,
ck_pr_fence_load(); ck_pr_fence_load();
tail.pointer = ck_pr_load_ptr(&fifo->tail.pointer); tail.pointer = ck_pr_load_ptr(&fifo->tail.pointer);
next.generation = ck_pr_load_ptr(&tail.pointer->next.generation); next.generation = ck_pr_load_ptr(&tail.pointer->next.generation);
ck_pr_fence_load();
next.pointer = ck_pr_load_ptr(&tail.pointer->next.pointer); next.pointer = ck_pr_load_ptr(&tail.pointer->next.pointer);
if (ck_pr_load_ptr(&fifo->tail.generation) != tail.generation) if (ck_pr_load_ptr(&fifo->tail.generation) != tail.generation)
@ -314,6 +315,7 @@ ck_fifo_mpmc_tryenqueue(struct ck_fifo_mpmc *fifo,
ck_pr_fence_load(); ck_pr_fence_load();
tail.pointer = ck_pr_load_ptr(&fifo->tail.pointer); tail.pointer = ck_pr_load_ptr(&fifo->tail.pointer);
next.generation = ck_pr_load_ptr(&tail.pointer->next.generation); next.generation = ck_pr_load_ptr(&tail.pointer->next.generation);
ck_pr_fence_load();
next.pointer = ck_pr_load_ptr(&tail.pointer->next.pointer); next.pointer = ck_pr_load_ptr(&tail.pointer->next.pointer);
if (ck_pr_load_ptr(&fifo->tail.generation) != tail.generation) if (ck_pr_load_ptr(&fifo->tail.generation) != tail.generation)
@ -365,6 +367,7 @@ ck_fifo_mpmc_dequeue(struct ck_fifo_mpmc *fifo,
tail.pointer = ck_pr_load_ptr(&fifo->tail.pointer); tail.pointer = ck_pr_load_ptr(&fifo->tail.pointer);
next.generation = ck_pr_load_ptr(&head.pointer->next.generation); next.generation = ck_pr_load_ptr(&head.pointer->next.generation);
ck_pr_fence_load();
next.pointer = ck_pr_load_ptr(&head.pointer->next.pointer); next.pointer = ck_pr_load_ptr(&head.pointer->next.pointer);
update.pointer = next.pointer; update.pointer = next.pointer;
@ -419,6 +422,7 @@ ck_fifo_mpmc_trydequeue(struct ck_fifo_mpmc *fifo,
tail.pointer = ck_pr_load_ptr(&fifo->tail.pointer); tail.pointer = ck_pr_load_ptr(&fifo->tail.pointer);
next.generation = ck_pr_load_ptr(&head.pointer->next.generation); next.generation = ck_pr_load_ptr(&head.pointer->next.generation);
ck_pr_fence_load();
next.pointer = ck_pr_load_ptr(&head.pointer->next.pointer); next.pointer = ck_pr_load_ptr(&head.pointer->next.pointer);
update.pointer = next.pointer; update.pointer = next.pointer;

Loading…
Cancel
Save