From bbad068f5a6e419fe8b991aa91a1c247ed3a3df6 Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Mon, 21 Apr 2014 16:47:21 -0400 Subject: [PATCH] ck_swlock: Make latch operation write-biased. --- include/ck_swlock.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/ck_swlock.h b/include/ck_swlock.h index 494b330..3081a3a 100644 --- a/include/ck_swlock.h +++ b/include/ck_swlock.h @@ -122,7 +122,10 @@ CK_CC_INLINE static void ck_swlock_write_latch(ck_swlock_t *rw) { - /* Stall until readers have seen the latch and cleared. */ + /* Publish intent to acquire lock. */ + ck_pr_or_32(&rw->value, CK_SWLOCK_WRITER_BIT); + + /* Stall until readers have seen the seen writer and cleared. */ while (ck_pr_cas_32(&rw->value, 0, CK_SWLOCK_WRITER_MASK) == false) { do { ck_pr_stall();