From: Mathieu Desnoyers Date: Sat, 22 Jun 2013 18:59:35 +0000 (-0400) Subject: doc/examples: add synchronize_rcu() X-Git-Tag: v0.8.0~20 X-Git-Url: https://git.lttng.org/?p=urcu.git;a=commitdiff_plain;h=d7818a6fd0c57b576f3bacc67ddd62bc8a78fb05 doc/examples: add synchronize_rcu() Signed-off-by: Mathieu Desnoyers --- diff --git a/doc/examples/urcu-flavors/mb.c b/doc/examples/urcu-flavors/mb.c index 757fe9e..62ad54b 100644 --- a/doc/examples/urcu-flavors/mb.c +++ b/doc/examples/urcu-flavors/mb.c @@ -117,6 +117,15 @@ int main(int argc, char **argv) call_rcu(&node->rcu_head, rcu_free_node); } + /* + * We can also wait for a quiescent state by calling + * synchronize_rcu() rather than using call_rcu(). It is usually + * a slower approach than call_rcu(), because the latter can + * batch work. Moreover, call_rcu() can be called from a RCU + * read-side critical section, but synchronize_rcu() should not. + */ + synchronize_rcu(); + sleep(1); /* diff --git a/doc/examples/urcu-flavors/membarrier.c b/doc/examples/urcu-flavors/membarrier.c index 0c5be4c..21f4579 100644 --- a/doc/examples/urcu-flavors/membarrier.c +++ b/doc/examples/urcu-flavors/membarrier.c @@ -116,6 +116,15 @@ int main(int argc, char **argv) call_rcu(&node->rcu_head, rcu_free_node); } + /* + * We can also wait for a quiescent state by calling + * synchronize_rcu() rather than using call_rcu(). It is usually + * a slower approach than call_rcu(), because the latter can + * batch work. Moreover, call_rcu() can be called from a RCU + * read-side critical section, but synchronize_rcu() should not. + */ + synchronize_rcu(); + sleep(1); /* diff --git a/doc/examples/urcu-flavors/qsbr.c b/doc/examples/urcu-flavors/qsbr.c index 6f5b9b5..1dbd546 100644 --- a/doc/examples/urcu-flavors/qsbr.c +++ b/doc/examples/urcu-flavors/qsbr.c @@ -126,6 +126,16 @@ int main(int argc, char **argv) rcu_thread_online(); + /* + * We can also wait for a quiescent state by calling + * synchronize_rcu() rather than using call_rcu(). It is usually + * a slower approach than call_rcu(), because the latter can + * batch work. Moreover, call_rcu() can be called from a RCU + * read-side critical section, but synchronize_rcu() ensures the + * caller thread is offline, thus acting as a quiescent state. + */ + synchronize_rcu(); + /* * Waiting for previously called call_rcu handlers to complete * before program exits, or in library destructors, is a good diff --git a/doc/examples/urcu-flavors/signal.c b/doc/examples/urcu-flavors/signal.c index b7c279c..136c380 100644 --- a/doc/examples/urcu-flavors/signal.c +++ b/doc/examples/urcu-flavors/signal.c @@ -116,6 +116,15 @@ int main(int argc, char **argv) call_rcu(&node->rcu_head, rcu_free_node); } + /* + * We can also wait for a quiescent state by calling + * synchronize_rcu() rather than using call_rcu(). It is usually + * a slower approach than call_rcu(), because the latter can + * batch work. Moreover, call_rcu() can be called from a RCU + * read-side critical section, but synchronize_rcu() should not. + */ + synchronize_rcu(); + sleep(1); /*