From 812cadd78037278561f699aedc71c4429af67b0c Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Mon, 28 Sep 2009 19:54:38 -0400 Subject: [PATCH] urcu (signal/mb): move thread checks outside lock Done on local variables, no need to lock. Signed-off-by: Mathieu Desnoyers --- urcu.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/urcu.c b/urcu.c index d441355..8e41d88 100644 --- a/urcu.c +++ b/urcu.c @@ -65,9 +65,6 @@ long urcu_gp_ctr = RCU_GP_COUNT; */ struct urcu_reader __thread urcu_reader; -/* Thread IDs of registered readers */ -#define INIT_NUM_THREADS 4 - #ifdef DEBUG_YIELD unsigned int yield_active; unsigned int __thread rand_yield; @@ -386,11 +383,12 @@ void *rcu_publish_content_sym(void **p, void *v) void rcu_register_thread(void) { - internal_urcu_lock(); - urcu_init(); /* In case gcc does not support constructor attribute */ urcu_reader.tid = pthread_self(); assert(urcu_reader.need_mb == 0); assert(urcu_reader.ctr == 0); + + internal_urcu_lock(); + urcu_init(); /* In case gcc does not support constructor attribute */ list_add(&urcu_reader.head, ®istry); internal_urcu_unlock(); } -- 2.34.1