doc/examples: enhance rcu-flavor-qsbr example
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sat, 22 Jun 2013 17:13:22 +0000 (13:13 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sat, 22 Jun 2013 17:13:22 +0000 (13:13 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
doc/examples/Makefile.am
doc/examples/rcu-flavor-qsbr/Makefile
doc/examples/rcu-flavor-qsbr/Makefile.rcu-flavor-qsbr [new file with mode: 0644]
doc/examples/rcu-flavor-qsbr/rcu-flavor-qsbr.c

index acdaaac1d9f2583b2fbf3c3aafded2b82761a116..74e2666316ab853da9ffd2066f5ca1907150af1b 100644 (file)
@@ -4,6 +4,7 @@ doc_examples_rcu_flavor_qsbrdir = ${doc_examplesdir}/rcu-flavor-qsbr
 
 dist_doc_examples_rcu_flavor_qsbr_DATA = \
        rcu-flavor-qsbr/Makefile \
+       rcu-flavor-qsbr/Makefile.rcu-flavor-qsbr \
        rcu-flavor-qsbr/rcu-flavor-qsbr.c
 
 dist_doc_examples_DATA = \
index b91d205096c78674fc34f826fd69a662d18ab07c..8e507222b64e10b87ee1db39c548120794621de7 100644 (file)
 #
 # This makefile is purposefully kept simple to support GNU and BSD make.
 
-CC = gcc
-LIBS = -lurcu-qsbr
-CFLAGS = -g -O2 -Wall
-OBJECTS = rcu-flavor-qsbr.o
-
-all: rcu-flavor-qsbr
-
-rcu-flavor-qsbr: $(OBJECTS)
-       $(CC) $(CFLAGS) $(LDFLAGS) $(AM_CFLAGS) $(AM_LDFLAGS) \
-               $(LIBS) -o $@ $(OBJECTS)
-
-rcu-flavor-qsbr.o: rcu-flavor-qsbr.c
-       $(CC) $(CPPFLAGS) $(CFLAGS) $(AM_CPPFLAGS) $(AM_CFLAGS) \
-               -c -o $@ $<
+all:
+       $(MAKE) -f Makefile.rcu-flavor-qsbr
 
 .PHONY: clean
 clean:
-       rm -f *.o rcu-flavor-qsbr
+       $(MAKE) -f Makefile.rcu-flavor-qsbr clean
diff --git a/doc/examples/rcu-flavor-qsbr/Makefile.rcu-flavor-qsbr b/doc/examples/rcu-flavor-qsbr/Makefile.rcu-flavor-qsbr
new file mode 100644 (file)
index 0000000..fc85278
--- /dev/null
@@ -0,0 +1,21 @@
+# Copyright (C) 2013  Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+#
+# THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
+# OR IMPLIED.  ANY USE IS AT YOUR OWN RISK.
+#
+# Permission is hereby granted to use or copy this program for any
+# purpose,  provided the above notices are retained on all copies.
+# Permission to modify the code and to distribute modified code is
+# granted, provided the above notices are retained, and a notice that
+# the code was modified is included with the above copyright notice.
+#
+# This makefile is purposefully kept simple to support GNU and BSD make.
+
+EXAMPLE_NAME = rcu-flavor-qsbr
+
+SOURCES = $(EXAMPLE_NAME).c
+OBJECTS = $(EXAMPLE_NAME).o
+BINARY = $(EXAMPLE_NAME)
+LIBS = -lurcu-qsbr
+
+include ../Makefile.examples.template
index a7a6ff45e01269b5f22b6ec0916064a653390511..2b722c0a1e0dcf1fda29236534b6f99758be6379 100644 (file)
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#define _LGPL_SOURCE
-#include <urcu-qsbr.h>
-#include <urcu/rculist.h>
-#include <urcu/compiler.h>
-
 #include <stdlib.h>
 #include <stdio.h>
 #include <stdint.h>
 #include <inttypes.h>
 
+#include <urcu-qsbr.h>         /* QSBR RCU flavor */
+#include <urcu/rculist.h>      /* List example */
+#include <urcu/compiler.h>     /* For CAA_ARRAY_SIZE */
+
 /*
  * This is a mock-up example where updates and RCU traversals are
  * performed by the same thread to keep things simple on purpose.
@@ -110,7 +109,9 @@ int main(int argc, char **argv)
 
        /*
         * For QSBR flavor, we need to explicitly announce quiescent
-        * states.
+        * states. Here is how it is done. This should be performed by
+        * every online registered RCU threads in the program
+        * periodically.
         */
        rcu_quiescent_state();
 
@@ -127,7 +128,8 @@ int main(int argc, char **argv)
 
        /*
         * Waiting for previously called call_rcu handlers to complete
-        * before program exits is a good practice.
+        * before program exits, or in library destructors, is a good
+        * practice.
         */
        rcu_barrier();
 
This page took 0.036009 seconds and 4 git commands to generate.