From eae4a518a834b6d5df12c4f6a4c2914cb17c28e0 Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Sun, 5 Feb 2012 14:27:02 -0500 Subject: [PATCH] ck_epoch: Differentiate read/write epoch endings. ck_epoch_end is deprecated. Please use ck_epoch_read_end and ck_epoch_write_end instead. --- include/ck_epoch.h | 11 ++++++++++- regressions/ck_epoch/validate/ck_stack.c | 4 ++-- regressions/ck_epoch/validate/ck_stack_read.c | 6 +++--- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/include/ck_epoch.h b/include/ck_epoch.h index fea24e7..23215dd 100644 --- a/include/ck_epoch.h +++ b/include/ck_epoch.h @@ -103,7 +103,16 @@ ck_epoch_read_begin(ck_epoch_record_t *record) } CK_CC_INLINE static void -ck_epoch_end(ck_epoch_record_t *record) +ck_epoch_read_end(ck_epoch_record_t *record) +{ + + ck_pr_fence_store(); + ck_pr_store_uint(&record->active, record->active - 1); + return; +} + +CK_CC_INLINE static void +ck_epoch_write_end(ck_epoch_record_t *record) { ck_pr_fence_store(); diff --git a/regressions/ck_epoch/validate/ck_stack.c b/regressions/ck_epoch/validate/ck_stack.c index 64e52ee..a5b9735 100644 --- a/regressions/ck_epoch/validate/ck_stack.c +++ b/regressions/ck_epoch/validate/ck_stack.c @@ -108,11 +108,11 @@ thread(void *unused CK_CC_UNUSED) for (i = 0; i < PAIRS; i++) { ck_epoch_write_begin(&record); ck_stack_push_upmc(&stack, &entry[i]->stack_entry); - ck_epoch_end(&record); + ck_epoch_write_end(&record); ck_epoch_write_begin(&record); s = ck_stack_pop_upmc(&stack); - ck_epoch_end(&record); + ck_epoch_write_end(&record); e = stack_container(s); ck_epoch_free(&record, &e->epoch_entry, destructor); diff --git a/regressions/ck_epoch/validate/ck_stack_read.c b/regressions/ck_epoch/validate/ck_stack_read.c index 5b78cda..c6f5a6c 100644 --- a/regressions/ck_epoch/validate/ck_stack_read.c +++ b/regressions/ck_epoch/validate/ck_stack_read.c @@ -117,7 +117,7 @@ read_thread(void *unused CK_CC_UNUSED) j++; n++; } - ck_epoch_end(&record); + ck_epoch_read_end(&record); if (j != 0 && ck_pr_load_uint(&readers) == 0) ck_pr_store_uint(&readers, 1); @@ -170,7 +170,7 @@ thread(void *unused CK_CC_UNUSED) for (i = 0; i < PAIRS; i++) { ck_epoch_write_begin(&record); ck_stack_push_upmc(&stack, &entry[i]->stack_entry); - ck_epoch_end(&record); + ck_epoch_write_end(&record); } while (ck_pr_load_uint(&readers) == 0) @@ -179,7 +179,7 @@ thread(void *unused CK_CC_UNUSED) for (i = 0; i < PAIRS; i++) { ck_epoch_write_begin(&record); s = ck_stack_pop_upmc(&stack); - ck_epoch_end(&record); + ck_epoch_write_end(&record); e = stack_container(s); ck_epoch_free(&record, &e->epoch_entry, destructor);