diff --git a/include/ck_brlock.h b/include/ck_brlock.h index 50a4f5e..cf44e64 100644 --- a/include/ck_brlock.h +++ b/include/ck_brlock.h @@ -147,12 +147,13 @@ ck_brlock_read_lock(struct ck_brlock *br, struct ck_brlock_reader *reader) while (ck_pr_load_uint(&br->writer) == true) ck_pr_stall(); - ck_pr_inc_uint(&reader->n_readers); + ck_pr_store_uint(&reader->n_readers, reader->n_readers + 1); + ck_pr_fence_strict_memory(); if (ck_pr_load_uint(&br->writer) == false) break; - ck_pr_dec_uint(&reader->n_readers); + ck_pr_store_uint(&reader->n_readers, reader->n_readers - 1); } return; @@ -162,7 +163,7 @@ CK_CC_INLINE static void ck_brlock_read_unlock(struct ck_brlock_reader *reader) { - ck_pr_dec_uint(&reader->n_readers); + ck_pr_store_uint(&reader->n_readers, reader->n_readers - 1); return; }