X-Git-Url: https://git.liburcu.org/?p=urcu.git;a=blobdiff_plain;f=urcu-qsbr.c;h=4ce2f9acdea1e1758f626f3dc14630922ab65be6;hp=c0f055441930ab8718cd4d4347325bd6671dc2fc;hb=ff2f67a0a2168bb1f0114af901e5e8e6ddce076b;hpb=d1238495fdaf1c85447690231bf5d1838b83bf88 diff --git a/urcu-qsbr.c b/urcu-qsbr.c index c0f0554..4ce2f9a 100644 --- a/urcu-qsbr.c +++ b/urcu-qsbr.c @@ -148,12 +148,27 @@ static void wait_for_quiescent_state(void) void synchronize_rcu(void) { + int was_online; + + was_online = rcu_reader_qs_gp & 1; + + /* + * Mark the writer thread offline to make sure we don't wait for + * our own quiescent state. This allows using synchronize_rcu() in + * threads registered as readers. + */ + if (was_online) + _rcu_thread_offline(); + internal_urcu_lock(); force_mb_all_threads(); urcu_gp_ctr += 2; wait_for_quiescent_state(); force_mb_all_threads(); internal_urcu_unlock(); + + if (was_online) + _rcu_thread_online(); } /*