From: Mathieu Desnoyers Date: Thu, 29 Nov 2018 20:59:18 +0000 (-0500) Subject: doc: update examples to API changes X-Git-Tag: v0.11.0~21 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=b9050d917ab84db192b5609ba6dd9973a82d215a;p=userspace-rcu.git doc: update examples to API changes Signed-off-by: Mathieu Desnoyers --- diff --git a/doc/examples/hlist/cds_hlist_add_head_rcu.c b/doc/examples/hlist/cds_hlist_add_head_rcu.c index 12161d1..bfe71c4 100644 --- a/doc/examples/hlist/cds_hlist_add_head_rcu.c +++ b/doc/examples/hlist/cds_hlist_add_head_rcu.c @@ -16,7 +16,7 @@ #include -#include /* Userspace RCU flavor */ +#include /* Userspace RCU flavor */ #include /* RCU hlist */ #include /* For CAA_ARRAY_SIZE */ diff --git a/doc/examples/hlist/cds_hlist_del_rcu.c b/doc/examples/hlist/cds_hlist_del_rcu.c index 1995b21..2c0008e 100644 --- a/doc/examples/hlist/cds_hlist_del_rcu.c +++ b/doc/examples/hlist/cds_hlist_del_rcu.c @@ -16,7 +16,7 @@ #include -#include /* Userspace RCU flavor */ +#include /* Userspace RCU flavor */ #include /* RCU hlist */ #include /* For CAA_ARRAY_SIZE */ @@ -72,7 +72,7 @@ int main(int argc, char **argv) * We can only reclaim memory after a grace * period has passed after cds_hlist_del_rcu(). */ - call_rcu(&node->rcu_head, free_node_rcu); + urcu_memb_call_rcu(&node->rcu_head, free_node_rcu); } } diff --git a/doc/examples/hlist/cds_hlist_for_each_entry_rcu.c b/doc/examples/hlist/cds_hlist_for_each_entry_rcu.c index f6b744a..5f8fa72 100644 --- a/doc/examples/hlist/cds_hlist_for_each_entry_rcu.c +++ b/doc/examples/hlist/cds_hlist_for_each_entry_rcu.c @@ -16,7 +16,7 @@ #include -#include /* Userspace RCU flavor */ +#include /* Userspace RCU flavor */ #include /* RCU hlist */ #include /* For CAA_ARRAY_SIZE */ @@ -40,7 +40,7 @@ int main(int argc, char **argv) * Each thread need using RCU read-side need to be explicitly * registered. */ - rcu_register_thread(); + urcu_memb_register_thread(); /* * Adding nodes to the linked-list. Safe against concurrent @@ -65,7 +65,7 @@ int main(int argc, char **argv) * Surround the RCU read-side critical section with rcu_read_lock() * and rcu_read_unlock(). */ - rcu_read_lock(); + urcu_memb_read_lock(); /* * This traversal can be performed concurrently with RCU @@ -75,10 +75,10 @@ int main(int argc, char **argv) printf(" %d", node->value); } - rcu_read_unlock(); + urcu_memb_read_unlock(); printf("\n"); end: - rcu_unregister_thread(); + urcu_memb_unregister_thread(); return ret; } diff --git a/doc/examples/hlist/cds_hlist_for_each_rcu.c b/doc/examples/hlist/cds_hlist_for_each_rcu.c index 47baa0e..fe31b54 100644 --- a/doc/examples/hlist/cds_hlist_for_each_rcu.c +++ b/doc/examples/hlist/cds_hlist_for_each_rcu.c @@ -19,7 +19,7 @@ #include -#include /* Userspace RCU flavor */ +#include /* Userspace RCU flavor */ #include /* RCU hlist */ #include /* For CAA_ARRAY_SIZE */ @@ -43,7 +43,7 @@ int main(int argc, char **argv) * Each thread need using RCU read-side need to be explicitly * registered. */ - rcu_register_thread(); + urcu_memb_register_thread(); /* * Adding nodes to the linked-list. Safe against concurrent @@ -70,7 +70,7 @@ int main(int argc, char **argv) * Surround the RCU read-side critical section with rcu_read_lock() * and rcu_read_unlock(). */ - rcu_read_lock(); + urcu_memb_read_lock(); /* * This traversal can be performed concurrently with RCU @@ -82,10 +82,10 @@ int main(int argc, char **argv) printf(" %d", node->value); } - rcu_read_unlock(); + urcu_memb_read_unlock(); printf("\n"); end: - rcu_unregister_thread(); + urcu_memb_unregister_thread(); return ret; } diff --git a/doc/examples/list/cds_list_add_rcu.c b/doc/examples/list/cds_list_add_rcu.c index ad1d909..4235d25 100644 --- a/doc/examples/list/cds_list_add_rcu.c +++ b/doc/examples/list/cds_list_add_rcu.c @@ -16,7 +16,7 @@ #include -#include /* Userspace RCU flavor */ +#include /* Userspace RCU flavor */ #include /* RCU list */ #include /* For CAA_ARRAY_SIZE */ diff --git a/doc/examples/list/cds_list_add_tail_rcu.c b/doc/examples/list/cds_list_add_tail_rcu.c index 53784c9..653da6c 100644 --- a/doc/examples/list/cds_list_add_tail_rcu.c +++ b/doc/examples/list/cds_list_add_tail_rcu.c @@ -16,7 +16,7 @@ #include -#include /* Userspace RCU flavor */ +#include /* Userspace RCU flavor */ #include /* RCU list */ #include /* For CAA_ARRAY_SIZE */ diff --git a/doc/examples/list/cds_list_del_rcu.c b/doc/examples/list/cds_list_del_rcu.c index c355101..1f4265c 100644 --- a/doc/examples/list/cds_list_del_rcu.c +++ b/doc/examples/list/cds_list_del_rcu.c @@ -16,7 +16,7 @@ #include -#include /* Userspace RCU flavor */ +#include /* Userspace RCU flavor */ #include /* RCU list */ #include /* For CAA_ARRAY_SIZE */ @@ -72,7 +72,7 @@ int main(int argc, char **argv) * We can only reclaim memory after a grace * period has passed after cds_list_del_rcu(). */ - call_rcu(&node->rcu_head, free_node_rcu); + urcu_memb_call_rcu(&node->rcu_head, free_node_rcu); } } diff --git a/doc/examples/list/cds_list_for_each_entry_rcu.c b/doc/examples/list/cds_list_for_each_entry_rcu.c index 777542b..6e4f7d6 100644 --- a/doc/examples/list/cds_list_for_each_entry_rcu.c +++ b/doc/examples/list/cds_list_for_each_entry_rcu.c @@ -16,7 +16,7 @@ #include -#include /* Userspace RCU flavor */ +#include /* Userspace RCU flavor */ #include /* RCU list */ #include /* For CAA_ARRAY_SIZE */ @@ -40,7 +40,7 @@ int main(int argc, char **argv) * Each thread need using RCU read-side need to be explicitly * registered. */ - rcu_register_thread(); + urcu_memb_register_thread(); /* * Adding nodes to the linked-list. Safe against concurrent @@ -62,10 +62,10 @@ int main(int argc, char **argv) printf("mylist content:"); /* - * Surround the RCU read-side critical section with rcu_read_lock() - * and rcu_read_unlock(). + * Surround the RCU read-side critical section with urcu_memb_read_lock() + * and urcu_memb_read_unlock(). */ - rcu_read_lock(); + urcu_memb_read_lock(); /* * This traversal can be performed concurrently with RCU @@ -75,10 +75,10 @@ int main(int argc, char **argv) printf(" %d", node->value); } - rcu_read_unlock(); + urcu_memb_read_unlock(); printf("\n"); end: - rcu_unregister_thread(); + urcu_memb_unregister_thread(); return ret; } diff --git a/doc/examples/list/cds_list_for_each_rcu.c b/doc/examples/list/cds_list_for_each_rcu.c index 86cc4ab..12d5c4d 100644 --- a/doc/examples/list/cds_list_for_each_rcu.c +++ b/doc/examples/list/cds_list_for_each_rcu.c @@ -18,7 +18,7 @@ #include -#include /* Userspace RCU flavor */ +#include /* Userspace RCU flavor */ #include /* RCU list */ #include /* For CAA_ARRAY_SIZE */ @@ -42,7 +42,7 @@ int main(int argc, char **argv) * Each thread need using RCU read-side need to be explicitly * registered. */ - rcu_register_thread(); + urcu_memb_register_thread(); /* * Adding nodes to the linked-list. Safe against concurrent @@ -66,10 +66,10 @@ int main(int argc, char **argv) printf("mylist content:"); /* - * Surround the RCU read-side critical section with rcu_read_lock() - * and rcu_read_unlock(). + * Surround the RCU read-side critical section with urcu_memb_read_lock() + * and urcu_memb_read_unlock(). */ - rcu_read_lock(); + urcu_memb_read_lock(); /* * This traversal can be performed concurrently with RCU @@ -81,10 +81,10 @@ int main(int argc, char **argv) printf(" %d", node->value); } - rcu_read_unlock(); + urcu_memb_read_unlock(); printf("\n"); end: - rcu_unregister_thread(); + urcu_memb_unregister_thread(); return ret; } diff --git a/doc/examples/list/cds_list_replace_rcu.c b/doc/examples/list/cds_list_replace_rcu.c index 4ccc1df..39202ea 100644 --- a/doc/examples/list/cds_list_replace_rcu.c +++ b/doc/examples/list/cds_list_replace_rcu.c @@ -16,7 +16,7 @@ #include -#include /* Userspace RCU flavor */ +#include /* Userspace RCU flavor */ #include /* RCU list */ #include /* For CAA_ARRAY_SIZE */ @@ -77,7 +77,7 @@ int main(int argc, char **argv) /* Replacement node value is negated original value. */ new_node->value = -node->value; cds_list_replace_rcu(&node->node, &new_node->node); - call_rcu(&node->rcu_head, free_node_rcu); + urcu_memb_call_rcu(&node->rcu_head, free_node_rcu); } /* diff --git a/doc/examples/rculfhash/cds_lfht_add.c b/doc/examples/rculfhash/cds_lfht_add.c index 8932e7a..acff676 100644 --- a/doc/examples/rculfhash/cds_lfht_add.c +++ b/doc/examples/rculfhash/cds_lfht_add.c @@ -19,7 +19,7 @@ #include #include -#include /* RCU flavor */ +#include /* RCU flavor */ #include /* RCU Lock-free hash table */ #include /* For CAA_ARRAY_SIZE */ #include "jhash.h" /* Example hash function */ @@ -46,7 +46,7 @@ int main(int argc, char **argv) * Each thread need using RCU read-side need to be explicitly * registered. */ - rcu_register_thread(); + urcu_memb_register_thread(); /* Use time as seed for hash table hashing. */ seed = (uint32_t) time(NULL); @@ -54,9 +54,9 @@ int main(int argc, char **argv) /* * Allocate hash table. */ - ht = cds_lfht_new(1, 1, 0, + ht = cds_lfht_new_flavor(1, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, - NULL); + &urcu_memb_flavor, NULL); if (!ht) { printf("Error allocating hash table\n"); ret = -1; @@ -83,9 +83,9 @@ int main(int argc, char **argv) * cds_lfht_add() needs to be called from RCU read-side * critical section. */ - rcu_read_lock(); + urcu_memb_read_lock(); cds_lfht_add(ht, hash, &node->node); - rcu_read_unlock(); + urcu_memb_read_unlock(); } /* @@ -94,13 +94,13 @@ int main(int argc, char **argv) * be performed within RCU read-side critical section. */ printf("hash table content (random order):"); - rcu_read_lock(); + urcu_memb_read_lock(); cds_lfht_for_each_entry(ht, &iter, node, node) { printf(" %d", node->value); } - rcu_read_unlock(); + urcu_memb_read_unlock(); printf("\n"); end: - rcu_unregister_thread(); + urcu_memb_unregister_thread(); return ret; } diff --git a/doc/examples/rculfhash/cds_lfht_add_replace.c b/doc/examples/rculfhash/cds_lfht_add_replace.c index 62de40c..19c3726 100644 --- a/doc/examples/rculfhash/cds_lfht_add_replace.c +++ b/doc/examples/rculfhash/cds_lfht_add_replace.c @@ -21,7 +21,7 @@ #include #include -#include /* RCU flavor */ +#include /* RCU flavor */ #include /* RCU Lock-free hash table */ #include /* For CAA_ARRAY_SIZE */ #include "jhash.h" /* Example hash function */ @@ -69,7 +69,7 @@ int main(int argc, char **argv) * Each thread need using RCU read-side need to be explicitly * registered. */ - rcu_register_thread(); + urcu_memb_register_thread(); /* Use time as seed for hash table hashing. */ seed = (uint32_t) time(NULL); @@ -77,9 +77,9 @@ int main(int argc, char **argv) /* * Allocate hash table. */ - ht = cds_lfht_new(1, 1, 0, + ht = cds_lfht_new_flavor(1, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, - NULL); + &urcu_memb_flavor, NULL); if (!ht) { printf("Error allocating hash table\n"); ret = -1; @@ -109,7 +109,7 @@ int main(int argc, char **argv) * cds_lfht_add() needs to be called from RCU read-side * critical section. */ - rcu_read_lock(); + urcu_memb_read_lock(); ht_node = cds_lfht_add_replace(ht, hash, match, &value, &node->node); if (ht_node) { @@ -119,12 +119,12 @@ int main(int argc, char **argv) printf("Replaced node (key: %d, seqnum: %d) by (key: %d, seqnum: %d)\n", ret_node->value, ret_node->seqnum, node->value, node->seqnum); - call_rcu(&ret_node->rcu_head, free_node); + urcu_memb_call_rcu(&ret_node->rcu_head, free_node); } else { printf("Add (key: %d, seqnum: %d)\n", node->value, node->seqnum); } - rcu_read_unlock(); + urcu_memb_read_unlock(); } /* @@ -133,15 +133,15 @@ int main(int argc, char **argv) * be performed within RCU read-side critical section. */ printf("hash table content (random order):"); - rcu_read_lock(); + urcu_memb_read_lock(); cds_lfht_for_each_entry(ht, &iter, node, node) { printf(" (key: %d, seqnum: %d)", node->value, node->seqnum); } - rcu_read_unlock(); + urcu_memb_read_unlock(); printf("\n"); end: - rcu_unregister_thread(); + urcu_memb_unregister_thread(); return ret; } diff --git a/doc/examples/rculfhash/cds_lfht_add_unique.c b/doc/examples/rculfhash/cds_lfht_add_unique.c index f1a7631..6875971 100644 --- a/doc/examples/rculfhash/cds_lfht_add_unique.c +++ b/doc/examples/rculfhash/cds_lfht_add_unique.c @@ -19,7 +19,7 @@ #include #include -#include /* RCU flavor */ +#include /* RCU flavor */ #include /* RCU Lock-free hash table */ #include /* For CAA_ARRAY_SIZE */ #include "jhash.h" /* Example hash function */ @@ -58,7 +58,7 @@ int main(int argc, char **argv) * Each thread need using RCU read-side need to be explicitly * registered. */ - rcu_register_thread(); + urcu_memb_register_thread(); /* Use time as seed for hash table hashing. */ seed = (uint32_t) time(NULL); @@ -66,9 +66,9 @@ int main(int argc, char **argv) /* * Allocate hash table. */ - ht = cds_lfht_new(1, 1, 0, + ht = cds_lfht_new_flavor(1, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, - NULL); + &urcu_memb_flavor, NULL); if (!ht) { printf("Error allocating hash table\n"); ret = -1; @@ -98,7 +98,7 @@ int main(int argc, char **argv) * cds_lfht_add() needs to be called from RCU read-side * critical section. */ - rcu_read_lock(); + urcu_memb_read_lock(); ht_node = cds_lfht_add_unique(ht, hash, match, &value, &node->node); /* @@ -121,7 +121,7 @@ int main(int argc, char **argv) printf("Add (key: %d, seqnum: %d)\n", node->value, node->seqnum); } - rcu_read_unlock(); + urcu_memb_read_unlock(); } /* @@ -130,15 +130,15 @@ int main(int argc, char **argv) * be performed within RCU read-side critical section. */ printf("hash table content (random order):"); - rcu_read_lock(); + urcu_memb_read_lock(); cds_lfht_for_each_entry(ht, &iter, node, node) { printf(" (key: %d, seqnum: %d)", node->value, node->seqnum); } - rcu_read_unlock(); + urcu_memb_read_unlock(); printf("\n"); end: - rcu_unregister_thread(); + urcu_memb_unregister_thread(); return ret; } diff --git a/doc/examples/rculfhash/cds_lfht_del.c b/doc/examples/rculfhash/cds_lfht_del.c index 4bcf15c..efa6d9a 100644 --- a/doc/examples/rculfhash/cds_lfht_del.c +++ b/doc/examples/rculfhash/cds_lfht_del.c @@ -18,7 +18,7 @@ #include #include -#include /* RCU flavor */ +#include /* RCU flavor */ #include /* RCU Lock-free hash table */ #include /* For CAA_ARRAY_SIZE */ #include "jhash.h" /* Example hash function */ @@ -66,7 +66,7 @@ int main(int argc, char **argv) * Each thread need using RCU read-side need to be explicitly * registered. */ - rcu_register_thread(); + urcu_memb_register_thread(); /* Use time as seed for hash table hashing. */ seed = (uint32_t) time(NULL); @@ -74,9 +74,9 @@ int main(int argc, char **argv) /* * Allocate hash table. */ - ht = cds_lfht_new(1, 1, 0, + ht = cds_lfht_new_flavor(1, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, - NULL); + &urcu_memb_flavor, NULL); if (!ht) { printf("Error allocating hash table\n"); ret = -1; @@ -105,9 +105,9 @@ int main(int argc, char **argv) * cds_lfht_add() needs to be called from RCU read-side * critical section. */ - rcu_read_lock(); + urcu_memb_read_lock(); cds_lfht_add(ht, hash, &node->node); - rcu_read_unlock(); + urcu_memb_read_unlock(); } /* @@ -116,11 +116,11 @@ int main(int argc, char **argv) * be performed within RCU read-side critical section. */ printf("hash table content (random order):"); - rcu_read_lock(); + urcu_memb_read_lock(); cds_lfht_for_each_entry(ht, &iter, node, node) { printf(" %d", node->value); } - rcu_read_unlock(); + urcu_memb_read_unlock(); printf("\n"); /* @@ -134,7 +134,7 @@ int main(int argc, char **argv) value = remove_values[i]; hash = jhash(&value, sizeof(value), seed); printf(" %d", value); - rcu_read_lock(); + urcu_memb_read_lock(); cds_lfht_lookup(ht, hash, match, &value, &iter); ht_node = cds_lfht_iter_get_node(&iter); if (ht_node) { @@ -145,24 +145,24 @@ int main(int argc, char **argv) struct mynode *del_node = caa_container_of(ht_node, struct mynode, node); - call_rcu(&del_node->rcu_head, free_node); + urcu_memb_call_rcu(&del_node->rcu_head, free_node); } } else { printf(" (not found)"); } - rcu_read_unlock(); + urcu_memb_read_unlock(); } printf("\n"); printf("hash table content (random order):"); - rcu_read_lock(); + urcu_memb_read_lock(); cds_lfht_for_each_entry(ht, &iter, node, node) { printf(" %d", node->value); } - rcu_read_unlock(); + urcu_memb_read_unlock(); printf("\n"); end: - rcu_unregister_thread(); + urcu_memb_unregister_thread(); return ret; } diff --git a/doc/examples/rculfhash/cds_lfht_destroy.c b/doc/examples/rculfhash/cds_lfht_destroy.c index d82d81c..1c723a5 100644 --- a/doc/examples/rculfhash/cds_lfht_destroy.c +++ b/doc/examples/rculfhash/cds_lfht_destroy.c @@ -19,7 +19,7 @@ #include #include -#include /* RCU flavor */ +#include /* RCU flavor */ #include /* RCU Lock-free hash table */ #include /* For CAA_ARRAY_SIZE */ #include "jhash.h" /* Example hash function */ @@ -56,7 +56,7 @@ int main(int argc, char **argv) * Each thread need using RCU read-side need to be explicitly * registered. */ - rcu_register_thread(); + urcu_memb_register_thread(); /* Use time as seed for hash table hashing. */ seed = (uint32_t) time(NULL); @@ -64,9 +64,9 @@ int main(int argc, char **argv) /* * Allocate hash table. */ - ht = cds_lfht_new(1, 1, 0, + ht = cds_lfht_new_flavor(1, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, - NULL); + &urcu_memb_flavor, NULL); if (!ht) { printf("Error allocating hash table\n"); ret = -1; @@ -95,9 +95,9 @@ int main(int argc, char **argv) * cds_lfht_add() needs to be called from RCU read-side * critical section. */ - rcu_read_lock(); + urcu_memb_read_lock(); cds_lfht_add(ht, hash, &node->node); - rcu_read_unlock(); + urcu_memb_read_unlock(); } /* @@ -106,11 +106,11 @@ int main(int argc, char **argv) * be performed within RCU read-side critical section. */ printf("hash table content (random order):"); - rcu_read_lock(); + urcu_memb_read_lock(); cds_lfht_for_each_entry(ht, &iter, node, node) { printf(" %d", node->value); } - rcu_read_unlock(); + urcu_memb_read_unlock(); printf("\n"); @@ -118,7 +118,7 @@ int main(int argc, char **argv) * Make sure all hash table nodes are removed before destroying. */ printf("removing all nodes:"); - rcu_read_lock(); + urcu_memb_read_lock(); cds_lfht_for_each_entry(ht, &iter, node, node) { ht_node = cds_lfht_iter_get_node(&iter); ret = cds_lfht_del(ht, ht_node); @@ -126,10 +126,10 @@ int main(int argc, char **argv) if (ret) { printf(" (concurrently deleted)"); } else { - call_rcu(&node->rcu_head, free_node); + urcu_memb_call_rcu(&node->rcu_head, free_node); } } - rcu_read_unlock(); + urcu_memb_read_unlock(); printf("\n"); /* @@ -144,6 +144,6 @@ int main(int argc, char **argv) printf("Destroying hash table failed\n"); } end: - rcu_unregister_thread(); + urcu_memb_unregister_thread(); return ret; } diff --git a/doc/examples/rculfhash/cds_lfht_for_each_entry_duplicate.c b/doc/examples/rculfhash/cds_lfht_for_each_entry_duplicate.c index e57509d..9833280 100644 --- a/doc/examples/rculfhash/cds_lfht_for_each_entry_duplicate.c +++ b/doc/examples/rculfhash/cds_lfht_for_each_entry_duplicate.c @@ -18,7 +18,7 @@ #include #include -#include /* RCU flavor */ +#include /* RCU flavor */ #include /* RCU Lock-free hash table */ #include /* For CAA_ARRAY_SIZE */ #include "jhash.h" /* Example hash function */ @@ -57,7 +57,7 @@ int main(int argc, char **argv) * Each thread need using RCU read-side need to be explicitly * registered. */ - rcu_register_thread(); + urcu_memb_register_thread(); /* Use time as seed for hash table hashing. */ seed = (uint32_t) time(NULL); @@ -65,9 +65,9 @@ int main(int argc, char **argv) /* * Allocate hash table. */ - ht = cds_lfht_new(1, 1, 0, + ht = cds_lfht_new_flavor(1, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, - NULL); + &urcu_memb_flavor, NULL); if (!ht) { printf("Error allocating hash table\n"); ret = -1; @@ -97,11 +97,11 @@ int main(int argc, char **argv) * cds_lfht_add() needs to be called from RCU read-side * critical section. */ - rcu_read_lock(); + urcu_memb_read_lock(); cds_lfht_add(ht, hash, &node->node); printf("Add (key: %d, seqnum: %d)\n", node->value, node->seqnum); - rcu_read_unlock(); + urcu_memb_read_unlock(); } /* @@ -110,12 +110,12 @@ int main(int argc, char **argv) * be performed within RCU read-side critical section. */ printf("hash table content (random order):"); - rcu_read_lock(); + urcu_memb_read_lock(); cds_lfht_for_each_entry(ht, &iter, node, node) { printf(" (key: %d, seqnum: %d)", node->value, node->seqnum); } - rcu_read_unlock(); + urcu_memb_read_unlock(); printf("\n"); /* @@ -128,16 +128,16 @@ int main(int argc, char **argv) unsigned long hash = jhash(&value, sizeof(value), seed); printf("lookup key: %d\n", value); - rcu_read_lock(); + urcu_memb_read_lock(); cds_lfht_for_each_entry_duplicate(ht, hash, match, &value, &iter, node, node) { printf(" (key %d, seqnum %d) found\n", node->value, node->seqnum); } - rcu_read_unlock(); + urcu_memb_read_unlock(); } end: - rcu_unregister_thread(); + urcu_memb_unregister_thread(); return ret; } diff --git a/doc/examples/rculfhash/cds_lfht_lookup.c b/doc/examples/rculfhash/cds_lfht_lookup.c index e76827b..053e6dd 100644 --- a/doc/examples/rculfhash/cds_lfht_lookup.c +++ b/doc/examples/rculfhash/cds_lfht_lookup.c @@ -18,7 +18,7 @@ #include #include -#include /* RCU flavor */ +#include /* RCU flavor */ #include /* RCU Lock-free hash table */ #include /* For CAA_ARRAY_SIZE */ #include "jhash.h" /* Example hash function */ @@ -58,7 +58,7 @@ int main(int argc, char **argv) * Each thread need using RCU read-side need to be explicitly * registered. */ - rcu_register_thread(); + urcu_memb_register_thread(); /* Use time as seed for hash table hashing. */ seed = (uint32_t) time(NULL); @@ -66,9 +66,9 @@ int main(int argc, char **argv) /* * Allocate hash table. */ - ht = cds_lfht_new(1, 1, 0, + ht = cds_lfht_new_flavor(1, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, - NULL); + &urcu_memb_flavor, NULL); if (!ht) { printf("Error allocating hash table\n"); ret = -1; @@ -98,11 +98,11 @@ int main(int argc, char **argv) * cds_lfht_add() needs to be called from RCU read-side * critical section. */ - rcu_read_lock(); + urcu_memb_read_lock(); cds_lfht_add(ht, hash, &node->node); printf("Add (key: %d, seqnum: %d)\n", node->value, node->seqnum); - rcu_read_unlock(); + urcu_memb_read_unlock(); } /* @@ -111,12 +111,12 @@ int main(int argc, char **argv) * be performed within RCU read-side critical section. */ printf("hash table content (random order):"); - rcu_read_lock(); + urcu_memb_read_lock(); cds_lfht_for_each_entry(ht, &iter, node, node) { printf(" (key: %d, seqnum: %d)", node->value, node->seqnum); } - rcu_read_unlock(); + urcu_memb_read_unlock(); printf("\n"); /* @@ -128,7 +128,7 @@ int main(int argc, char **argv) int value = lookup_values[i]; unsigned long hash = jhash(&value, sizeof(value), seed); - rcu_read_lock(); + urcu_memb_read_lock(); cds_lfht_lookup(ht, hash, match, &value, &iter); ht_node = cds_lfht_iter_get_node(&iter); if (!ht_node) { @@ -138,10 +138,10 @@ int main(int argc, char **argv) printf("(key %d, seqnum %d) found\n", node->value, node->seqnum); } - rcu_read_unlock(); + urcu_memb_read_unlock(); } end: - rcu_unregister_thread(); + urcu_memb_unregister_thread(); return ret; } diff --git a/doc/examples/rculfqueue/cds_lfq_dequeue.c b/doc/examples/rculfqueue/cds_lfq_dequeue.c index d1375c8..fc8053c 100644 --- a/doc/examples/rculfqueue/cds_lfq_dequeue.c +++ b/doc/examples/rculfqueue/cds_lfq_dequeue.c @@ -17,7 +17,7 @@ #include #include -#include /* RCU flavor */ +#include /* RCU flavor */ #include /* RCU Lock-free queue */ #include /* For CAA_ARRAY_SIZE */ @@ -50,9 +50,9 @@ int main(int argc, char **argv) * Each thread need using RCU read-side need to be explicitly * registered. */ - rcu_register_thread(); + urcu_memb_register_thread(); - cds_lfq_init_rcu(&myqueue, call_rcu); + cds_lfq_init_rcu(&myqueue, urcu_memb_call_rcu); /* * Enqueue nodes. @@ -72,9 +72,9 @@ int main(int argc, char **argv) * Both enqueue and dequeue need to be called within RCU * read-side critical section. */ - rcu_read_lock(); + urcu_memb_read_lock(); cds_lfq_enqueue_rcu(&myqueue, &node->node); - rcu_read_unlock(); + urcu_memb_read_unlock(); } /* @@ -90,16 +90,16 @@ int main(int argc, char **argv) * Both enqueue and dequeue need to be called within RCU * read-side critical section. */ - rcu_read_lock(); + urcu_memb_read_lock(); qnode = cds_lfq_dequeue_rcu(&myqueue); - rcu_read_unlock(); + urcu_memb_read_unlock(); if (!qnode) { break; /* Queue is empty. */ } /* Getting the container structure from the node */ node = caa_container_of(qnode, struct mynode, node); printf(" %d", node->value); - call_rcu(&node->rcu_head, free_node); + urcu_memb_call_rcu(&node->rcu_head, free_node); } printf("\n"); /* @@ -110,6 +110,6 @@ int main(int argc, char **argv) printf("Error destroying queue (non-empty)\n"); } end: - rcu_unregister_thread(); + urcu_memb_unregister_thread(); return ret; } diff --git a/doc/examples/rculfqueue/cds_lfq_enqueue.c b/doc/examples/rculfqueue/cds_lfq_enqueue.c index a8c6f86..1e78f16 100644 --- a/doc/examples/rculfqueue/cds_lfq_enqueue.c +++ b/doc/examples/rculfqueue/cds_lfq_enqueue.c @@ -17,7 +17,7 @@ #include #include -#include /* RCU flavor */ +#include /* RCU flavor */ #include /* RCU Lock-free queue */ #include /* For CAA_ARRAY_SIZE */ @@ -40,9 +40,9 @@ int main(int argc, char **argv) * Each thread need using RCU read-side need to be explicitly * registered. */ - rcu_register_thread(); + urcu_memb_register_thread(); - cds_lfq_init_rcu(&myqueue, call_rcu); + cds_lfq_init_rcu(&myqueue, urcu_memb_call_rcu); /* * Enqueue nodes. @@ -62,12 +62,12 @@ int main(int argc, char **argv) * Both enqueue and dequeue need to be called within RCU * read-side critical section. */ - rcu_read_lock(); + urcu_memb_read_lock(); cds_lfq_enqueue_rcu(&myqueue, &node->node); - rcu_read_unlock(); + urcu_memb_read_unlock(); } end: - rcu_unregister_thread(); + urcu_memb_unregister_thread(); return ret; } diff --git a/doc/examples/urcu-flavors/bp.c b/doc/examples/urcu-flavors/bp.c index 64978fc..1875a86 100644 --- a/doc/examples/urcu-flavors/bp.c +++ b/doc/examples/urcu-flavors/bp.c @@ -22,7 +22,7 @@ #include #include -#include /* Bulletproof RCU flavor */ +#include /* Bulletproof RCU flavor */ #include /* List example */ #include /* For CAA_ARRAY_SIZE */ @@ -81,7 +81,7 @@ int main(int argc, char **argv) * with rcu_read_lock() and rcu_read_unlock(). They can be * nested. Those are no-ops for the QSBR flavor. */ - rcu_read_lock(); + urcu_bp_read_lock(); /* * RCU traversal of the linked list. @@ -89,7 +89,7 @@ int main(int argc, char **argv) cds_list_for_each_entry_rcu(node, &mylist, node) { printf("Value: %" PRIu64 "\n", node->value); } - rcu_read_unlock(); + urcu_bp_read_unlock(); /* * Removing nodes from linked list. Safe against concurrent RCU @@ -104,7 +104,7 @@ int main(int argc, char **argv) * spawning any call_rcu() thread. It is slower though, * since there is no batching. */ - synchronize_rcu(); + urcu_bp_synchronize_rcu(); free(node); } diff --git a/doc/examples/urcu-flavors/mb.c b/doc/examples/urcu-flavors/mb.c index 62ad54b..e103e4f 100644 --- a/doc/examples/urcu-flavors/mb.c +++ b/doc/examples/urcu-flavors/mb.c @@ -22,8 +22,7 @@ #include #include -#define RCU_MB /* Memory barrier RCU flavor */ -#include +#include /* Memory barrier RCU flavor */ #include /* List example */ #include /* For CAA_ARRAY_SIZE */ @@ -75,7 +74,7 @@ int main(int argc, char **argv) * Each thread need using RCU read-side need to be explicitly * registered. */ - rcu_register_thread(); + urcu_mb_register_thread(); /* * Adding nodes to the linked-list. Safe against concurrent @@ -92,7 +91,7 @@ int main(int argc, char **argv) * with rcu_read_lock() and rcu_read_unlock(). They can be * nested. Those are no-ops for the QSBR flavor. */ - rcu_read_lock(); + urcu_mb_read_lock(); /* * RCU traversal of the linked list. @@ -100,7 +99,7 @@ int main(int argc, char **argv) cds_list_for_each_entry_rcu(node, &mylist, node) { printf("Value: %" PRIu64 "\n", node->value); } - rcu_read_unlock(); + urcu_mb_read_unlock(); /* * Removing nodes from linked list. Safe against concurrent RCU @@ -114,7 +113,7 @@ int main(int argc, char **argv) * call_rcu() can be called from RCU read-side critical * sections. */ - call_rcu(&node->rcu_head, rcu_free_node); + urcu_mb_call_rcu(&node->rcu_head, rcu_free_node); } /* @@ -124,7 +123,7 @@ int main(int argc, char **argv) * batch work. Moreover, call_rcu() can be called from a RCU * read-side critical section, but synchronize_rcu() should not. */ - synchronize_rcu(); + urcu_mb_synchronize_rcu(); sleep(1); @@ -133,9 +132,9 @@ int main(int argc, char **argv) * before program exits, or in library destructors, is a good * practice. */ - rcu_barrier(); + urcu_mb_barrier(); end: - rcu_unregister_thread(); + urcu_mb_unregister_thread(); return ret; } diff --git a/doc/examples/urcu-flavors/membarrier.c b/doc/examples/urcu-flavors/membarrier.c index 21f4579..f9523d5 100644 --- a/doc/examples/urcu-flavors/membarrier.c +++ b/doc/examples/urcu-flavors/membarrier.c @@ -22,7 +22,7 @@ #include #include -#include /* Default: sys_membarrier() RCU flavor */ +#include /* sys_membarrier() RCU flavor */ #include /* List example */ #include /* For CAA_ARRAY_SIZE */ @@ -74,7 +74,7 @@ int main(int argc, char **argv) * Each thread need using RCU read-side need to be explicitly * registered. */ - rcu_register_thread(); + urcu_memb_register_thread(); /* * Adding nodes to the linked-list. Safe against concurrent @@ -91,7 +91,7 @@ int main(int argc, char **argv) * with rcu_read_lock() and rcu_read_unlock(). They can be * nested. Those are no-ops for the QSBR flavor. */ - rcu_read_lock(); + urcu_memb_read_lock(); /* * RCU traversal of the linked list. @@ -99,7 +99,7 @@ int main(int argc, char **argv) cds_list_for_each_entry_rcu(node, &mylist, node) { printf("Value: %" PRIu64 "\n", node->value); } - rcu_read_unlock(); + urcu_memb_read_unlock(); /* * Removing nodes from linked list. Safe against concurrent RCU @@ -113,7 +113,7 @@ int main(int argc, char **argv) * call_rcu() can be called from RCU read-side critical * sections. */ - call_rcu(&node->rcu_head, rcu_free_node); + urcu_memb_call_rcu(&node->rcu_head, rcu_free_node); } /* @@ -123,7 +123,7 @@ int main(int argc, char **argv) * batch work. Moreover, call_rcu() can be called from a RCU * read-side critical section, but synchronize_rcu() should not. */ - synchronize_rcu(); + urcu_memb_synchronize_rcu(); sleep(1); @@ -132,9 +132,9 @@ int main(int argc, char **argv) * before program exits, or in library destructors, is a good * practice. */ - rcu_barrier(); + urcu_memb_barrier(); end: - rcu_unregister_thread(); + urcu_memb_unregister_thread(); return ret; } diff --git a/doc/examples/urcu-flavors/qsbr.c b/doc/examples/urcu-flavors/qsbr.c index 1dbd546..7af8ada 100644 --- a/doc/examples/urcu-flavors/qsbr.c +++ b/doc/examples/urcu-flavors/qsbr.c @@ -22,7 +22,7 @@ #include #include -#include /* QSBR RCU flavor */ +#include /* QSBR RCU flavor */ #include /* List example */ #include /* For CAA_ARRAY_SIZE */ @@ -73,7 +73,7 @@ int main(int argc, char **argv) * Each thread need using RCU read-side need to be explicitly * registered. */ - rcu_register_thread(); + urcu_qsbr_register_thread(); /* * Adding nodes to the linked-list. Safe against concurrent @@ -104,7 +104,7 @@ int main(int argc, char **argv) * call_rcu() can be called from RCU read-side critical * sections. */ - call_rcu(&node->rcu_head, rcu_free_node); + urcu_qsbr_call_rcu(&node->rcu_head, rcu_free_node); } /* @@ -113,18 +113,18 @@ int main(int argc, char **argv) * every online registered RCU threads in the program * periodically. */ - rcu_quiescent_state(); + urcu_qsbr_quiescent_state(); /* * For QSBR flavor, when a thread needs to be in a quiescent * state for a long period of time, we use rcu_thread_offline() * and rcu_thread_online(). */ - rcu_thread_offline(); + urcu_qsbr_thread_offline(); sleep(1); - rcu_thread_online(); + urcu_qsbr_thread_online(); /* * We can also wait for a quiescent state by calling @@ -134,16 +134,16 @@ int main(int argc, char **argv) * read-side critical section, but synchronize_rcu() ensures the * caller thread is offline, thus acting as a quiescent state. */ - synchronize_rcu(); + urcu_qsbr_synchronize_rcu(); /* * Waiting for previously called call_rcu handlers to complete * before program exits, or in library destructors, is a good * practice. */ - rcu_barrier(); + urcu_qsbr_barrier(); end: - rcu_unregister_thread(); + urcu_qsbr_unregister_thread(); return ret; } diff --git a/doc/examples/urcu-flavors/signal.c b/doc/examples/urcu-flavors/signal.c index 136c380..e396b9e 100644 --- a/doc/examples/urcu-flavors/signal.c +++ b/doc/examples/urcu-flavors/signal.c @@ -22,8 +22,7 @@ #include #include -#define RCU_SIGNAL /* Signal-based RCU flavor */ -#include +#include /* Signal-based RCU flavor */ #include /* List example */ #include /* For CAA_ARRAY_SIZE */ @@ -74,7 +73,7 @@ int main(int argc, char **argv) * Each thread need using RCU read-side need to be explicitly * registered. */ - rcu_register_thread(); + urcu_signal_register_thread(); /* * Adding nodes to the linked-list. Safe against concurrent @@ -91,7 +90,7 @@ int main(int argc, char **argv) * with rcu_read_lock() and rcu_read_unlock(). They can be * nested. Those are no-ops for the QSBR flavor. */ - rcu_read_lock(); + urcu_signal_read_lock(); /* * RCU traversal of the linked list. @@ -99,7 +98,7 @@ int main(int argc, char **argv) cds_list_for_each_entry_rcu(node, &mylist, node) { printf("Value: %" PRIu64 "\n", node->value); } - rcu_read_unlock(); + urcu_signal_read_unlock(); /* * Removing nodes from linked list. Safe against concurrent RCU @@ -113,7 +112,7 @@ int main(int argc, char **argv) * call_rcu() can be called from RCU read-side critical * sections. */ - call_rcu(&node->rcu_head, rcu_free_node); + urcu_signal_call_rcu(&node->rcu_head, rcu_free_node); } /* @@ -123,7 +122,7 @@ int main(int argc, char **argv) * batch work. Moreover, call_rcu() can be called from a RCU * read-side critical section, but synchronize_rcu() should not. */ - synchronize_rcu(); + urcu_signal_synchronize_rcu(); sleep(1); @@ -132,9 +131,9 @@ int main(int argc, char **argv) * before program exits, or in library destructors, is a good * practice. */ - rcu_barrier(); + urcu_signal_barrier(); end: - rcu_unregister_thread(); + urcu_signal_unregister_thread(); return ret; }