From 135530fd6a47925c76a3e828f2fc7d6751bc9ff7 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Thu, 12 Feb 2009 01:43:54 -0500 Subject: [PATCH] Fix force_mb_all_threads must be called within internal local It iterates on threads, and must therefore be called within the mutex. Signed-off-by: Mathieu Desnoyers --- urcu.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/urcu.c b/urcu.c index 0e42207..f2aae34 100644 --- a/urcu.c +++ b/urcu.c @@ -152,13 +152,14 @@ void wait_for_quiescent_state(void) void synchronize_rcu(void) { + internal_urcu_lock(); + /* All threads should read qparity before accessing data structure - * where new ptr points to. */ + * where new ptr points to. Must be done within internal_urcu_lock + * because it iterates on reader threads.*/ /* Write new ptr before changing the qparity */ force_mb_all_threads(); - internal_urcu_lock(); - switch_next_urcu_qparity(); /* 0 -> 1 */ /* @@ -197,13 +198,12 @@ void synchronize_rcu(void) */ wait_for_quiescent_state(); /* Wait readers in parity 1 */ - internal_urcu_unlock(); - - /* All threads should finish using the data referred to by old ptr - * before decrementing their urcu_active_readers count */ /* Finish waiting for reader threads before letting the old ptr being - * freed. */ + * freed. Must be done within internal_urcu_lock because it iterates on + * reader threads. */ force_mb_all_threads(); + + internal_urcu_unlock(); } void urcu_add_reader(pthread_t id) -- 2.34.1