doc/examples: add synchronize_rcu()
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sat, 22 Jun 2013 18:59:35 +0000 (14:59 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sat, 22 Jun 2013 18:59:35 +0000 (14:59 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
doc/examples/urcu-flavors/mb.c
doc/examples/urcu-flavors/membarrier.c
doc/examples/urcu-flavors/qsbr.c
doc/examples/urcu-flavors/signal.c

index 757fe9e0a7e3acae21bab6b59300a88c2f34d83d..62ad54bb7ff00309f7de7572116de1222bd8b7ee 100644 (file)
@@ -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);
 
        /*
index 0c5be4c0aeae946dbd9c645273d318b8dfdf1231..21f4579972193497366eacb8d137c001bce1c3f4 100644 (file)
@@ -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);
 
        /*
index 6f5b9b51d46b796adcaf26792dcfcfd5eb1b1c4f..1dbd54635cbe06a4ca71bb9a60fdb87bcb8c9dec 100644 (file)
@@ -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
index b7c279c9157732cbb4084ec1c2b041be2958a368..136c3801f887e132e6da32df32be9eac4926b5e7 100644 (file)
@@ -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);
 
        /*
This page took 0.026501 seconds and 4 git commands to generate.