ck_swlock: Switch to TATAS style loop for latch operations.

ck_pring
Samy Al Bahra 11 years ago
parent 82f33b3fe9
commit a1daff18ea

@ -124,12 +124,14 @@ ck_swlock_write_latch(ck_swlock_t *rw)
{ {
ck_pr_store_32(&rw->writer, 1); ck_pr_store_32(&rw->writer, 1);
ck_pr_fence_atomic_load(); ck_pr_fence_atomic_load();
/* Stall until readers have seen the latch and cleared. */ /* Stall until readers have seen the latch and cleared. */
while (ck_pr_cas_32(&rw->n_readers, 0, CK_SWLOCK_LATCH_BIT) == false) while (ck_pr_cas_32(&rw->n_readers, 0, CK_SWLOCK_LATCH_BIT) == false) {
do {
ck_pr_stall(); ck_pr_stall();
} while (ck_pr_load_uint(&rw->n_readers) != 0);
}
return; return;
} }
@ -292,8 +294,11 @@ ck_swlock_recursive_write_latch(ck_swlock_recursive_t *rw)
ck_pr_store_32(&rw->rw.writer, 1); ck_pr_store_32(&rw->rw.writer, 1);
ck_pr_fence_store_load(); ck_pr_fence_store_load();
while (ck_pr_cas_32(&rw->rw.n_readers, 0, CK_SWLOCK_LATCH_BIT) == false) while (ck_pr_cas_32(&rw->rw.n_readers, 0, CK_SWLOCK_LATCH_BIT) == false) {
do {
ck_pr_stall(); ck_pr_stall();
} while (ck_pr_load_uint(&rw->n_readers) != 0);
}
rw->wc++; rw->wc++;
return; return;

Loading…
Cancel
Save