ck_rwlock: Re-observe latch bits if necessary.

ck_pring
Samy Al Bahra 11 years ago
parent 7f945460bc
commit fa28622386

@ -213,8 +213,21 @@ ck_rwlock_read_lock(ck_rwlock_t *rw)
*/
ck_pr_fence_atomic_load();
if (ck_pr_load_32(&rw->writer) == 0)
if (ck_pr_load_32(&rw->writer) == 0) {
/*
* It is possible that a latch operation has itself
* gone unnoticed across a write-side critical section.
* However, the write-side critical section itself
* guarantees an ordering with respect to the previous
* fence operation. If writer is observed to 0, then
* it is guaranteed that the latch will be visible.
*/
snapshot = ck_pr_load_32(&rw->n_readers);
if (snapshot >> CK_RWLOCK_LATCH_SHIFT)
continue;
break;
}
ck_pr_dec_32(&rw->n_readers);
}

Loading…
Cancel
Save