#include <stdio.h>
-#include <urcu.h> /* Userspace RCU flavor */
+#include <urcu/urcu-memb.h> /* Userspace RCU flavor */
#include <urcu/rcuhlist.h> /* RCU hlist */
#include <urcu/compiler.h> /* For CAA_ARRAY_SIZE */
#include <stdio.h>
-#include <urcu.h> /* Userspace RCU flavor */
+#include <urcu/urcu-memb.h> /* Userspace RCU flavor */
#include <urcu/rcuhlist.h> /* RCU hlist */
#include <urcu/compiler.h> /* For CAA_ARRAY_SIZE */
* 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);
}
}
#include <stdio.h>
-#include <urcu.h> /* Userspace RCU flavor */
+#include <urcu/urcu-memb.h> /* Userspace RCU flavor */
#include <urcu/rcuhlist.h> /* RCU hlist */
#include <urcu/compiler.h> /* For CAA_ARRAY_SIZE */
* 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
* 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
printf(" %d", node->value);
}
- rcu_read_unlock();
+ urcu_memb_read_unlock();
printf("\n");
end:
- rcu_unregister_thread();
+ urcu_memb_unregister_thread();
return ret;
}
#include <stdio.h>
-#include <urcu.h> /* Userspace RCU flavor */
+#include <urcu/urcu-memb.h> /* Userspace RCU flavor */
#include <urcu/rcuhlist.h> /* RCU hlist */
#include <urcu/compiler.h> /* For CAA_ARRAY_SIZE */
* 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
* 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
printf(" %d", node->value);
}
- rcu_read_unlock();
+ urcu_memb_read_unlock();
printf("\n");
end:
- rcu_unregister_thread();
+ urcu_memb_unregister_thread();
return ret;
}
#include <stdio.h>
-#include <urcu.h> /* Userspace RCU flavor */
+#include <urcu/urcu-memb.h> /* Userspace RCU flavor */
#include <urcu/rculist.h> /* RCU list */
#include <urcu/compiler.h> /* For CAA_ARRAY_SIZE */
#include <stdio.h>
-#include <urcu.h> /* Userspace RCU flavor */
+#include <urcu/urcu-memb.h> /* Userspace RCU flavor */
#include <urcu/rculist.h> /* RCU list */
#include <urcu/compiler.h> /* For CAA_ARRAY_SIZE */
#include <stdio.h>
-#include <urcu.h> /* Userspace RCU flavor */
+#include <urcu/urcu-memb.h> /* Userspace RCU flavor */
#include <urcu/rculist.h> /* RCU list */
#include <urcu/compiler.h> /* For CAA_ARRAY_SIZE */
* 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);
}
}
#include <stdio.h>
-#include <urcu.h> /* Userspace RCU flavor */
+#include <urcu/urcu-memb.h> /* Userspace RCU flavor */
#include <urcu/rculist.h> /* RCU list */
#include <urcu/compiler.h> /* For CAA_ARRAY_SIZE */
* 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
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
printf(" %d", node->value);
}
- rcu_read_unlock();
+ urcu_memb_read_unlock();
printf("\n");
end:
- rcu_unregister_thread();
+ urcu_memb_unregister_thread();
return ret;
}
#include <stdio.h>
-#include <urcu.h> /* Userspace RCU flavor */
+#include <urcu/urcu-memb.h> /* Userspace RCU flavor */
#include <urcu/rculist.h> /* RCU list */
#include <urcu/compiler.h> /* For CAA_ARRAY_SIZE */
* 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
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
printf(" %d", node->value);
}
- rcu_read_unlock();
+ urcu_memb_read_unlock();
printf("\n");
end:
- rcu_unregister_thread();
+ urcu_memb_unregister_thread();
return ret;
}
#include <stdio.h>
-#include <urcu.h> /* Userspace RCU flavor */
+#include <urcu/urcu-memb.h> /* Userspace RCU flavor */
#include <urcu/rculist.h> /* RCU list */
#include <urcu/compiler.h> /* For CAA_ARRAY_SIZE */
/* 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);
}
/*
#include <stdlib.h>
#include <time.h>
-#include <urcu.h> /* RCU flavor */
+#include <urcu/urcu-memb.h> /* RCU flavor */
#include <urcu/rculfhash.h> /* RCU Lock-free hash table */
#include <urcu/compiler.h> /* For CAA_ARRAY_SIZE */
#include "jhash.h" /* Example hash function */
* 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);
/*
* 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;
* 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();
}
/*
* 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;
}
#include <stdlib.h>
#include <time.h>
-#include <urcu.h> /* RCU flavor */
+#include <urcu/urcu-memb.h> /* RCU flavor */
#include <urcu/rculfhash.h> /* RCU Lock-free hash table */
#include <urcu/compiler.h> /* For CAA_ARRAY_SIZE */
#include "jhash.h" /* Example hash function */
* 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);
/*
* 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;
* 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) {
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();
}
/*
* 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;
}
#include <stdlib.h>
#include <time.h>
-#include <urcu.h> /* RCU flavor */
+#include <urcu/urcu-memb.h> /* RCU flavor */
#include <urcu/rculfhash.h> /* RCU Lock-free hash table */
#include <urcu/compiler.h> /* For CAA_ARRAY_SIZE */
#include "jhash.h" /* Example hash function */
* 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);
/*
* 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;
* 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);
/*
printf("Add (key: %d, seqnum: %d)\n",
node->value, node->seqnum);
}
- rcu_read_unlock();
+ urcu_memb_read_unlock();
}
/*
* 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;
}
#include <stdlib.h>
#include <time.h>
-#include <urcu.h> /* RCU flavor */
+#include <urcu/urcu-memb.h> /* RCU flavor */
#include <urcu/rculfhash.h> /* RCU Lock-free hash table */
#include <urcu/compiler.h> /* For CAA_ARRAY_SIZE */
#include "jhash.h" /* Example hash function */
* 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);
/*
* 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;
* 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();
}
/*
* 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");
/*
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) {
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;
}
#include <stdlib.h>
#include <time.h>
-#include <urcu.h> /* RCU flavor */
+#include <urcu/urcu-memb.h> /* RCU flavor */
#include <urcu/rculfhash.h> /* RCU Lock-free hash table */
#include <urcu/compiler.h> /* For CAA_ARRAY_SIZE */
#include "jhash.h" /* Example hash function */
* 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);
/*
* 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;
* 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();
}
/*
* 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");
* 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);
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");
/*
printf("Destroying hash table failed\n");
}
end:
- rcu_unregister_thread();
+ urcu_memb_unregister_thread();
return ret;
}
#include <stdlib.h>
#include <time.h>
-#include <urcu.h> /* RCU flavor */
+#include <urcu/urcu-memb.h> /* RCU flavor */
#include <urcu/rculfhash.h> /* RCU Lock-free hash table */
#include <urcu/compiler.h> /* For CAA_ARRAY_SIZE */
#include "jhash.h" /* Example hash function */
* 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);
/*
* 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;
* 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();
}
/*
* 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");
/*
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;
}
#include <stdlib.h>
#include <time.h>
-#include <urcu.h> /* RCU flavor */
+#include <urcu/urcu-memb.h> /* RCU flavor */
#include <urcu/rculfhash.h> /* RCU Lock-free hash table */
#include <urcu/compiler.h> /* For CAA_ARRAY_SIZE */
#include "jhash.h" /* Example hash function */
* 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);
/*
* 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;
* 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();
}
/*
* 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");
/*
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) {
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;
}
#include <stdio.h>
#include <stdlib.h>
-#include <urcu.h> /* RCU flavor */
+#include <urcu/urcu-memb.h> /* RCU flavor */
#include <urcu/rculfqueue.h> /* RCU Lock-free queue */
#include <urcu/compiler.h> /* For CAA_ARRAY_SIZE */
* 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.
* 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();
}
/*
* 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");
/*
printf("Error destroying queue (non-empty)\n");
}
end:
- rcu_unregister_thread();
+ urcu_memb_unregister_thread();
return ret;
}
#include <stdio.h>
#include <stdlib.h>
-#include <urcu.h> /* RCU flavor */
+#include <urcu/urcu-memb.h> /* RCU flavor */
#include <urcu/rculfqueue.h> /* RCU Lock-free queue */
#include <urcu/compiler.h> /* For CAA_ARRAY_SIZE */
* 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.
* 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;
}
#include <stdint.h>
#include <inttypes.h>
-#include <urcu-bp.h> /* Bulletproof RCU flavor */
+#include <urcu/urcu-bp.h> /* Bulletproof RCU flavor */
#include <urcu/rculist.h> /* List example */
#include <urcu/compiler.h> /* For CAA_ARRAY_SIZE */
* 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.
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
* spawning any call_rcu() thread. It is slower though,
* since there is no batching.
*/
- synchronize_rcu();
+ urcu_bp_synchronize_rcu();
free(node);
}
#include <stdint.h>
#include <inttypes.h>
-#define RCU_MB /* Memory barrier RCU flavor */
-#include <urcu.h>
+#include <urcu/urcu-mb.h> /* Memory barrier RCU flavor */
#include <urcu/rculist.h> /* List example */
#include <urcu/compiler.h> /* For CAA_ARRAY_SIZE */
* 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
* 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.
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
* 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);
}
/*
* 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);
* 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;
}
#include <stdint.h>
#include <inttypes.h>
-#include <urcu.h> /* Default: sys_membarrier() RCU flavor */
+#include <urcu/urcu-memb.h> /* sys_membarrier() RCU flavor */
#include <urcu/rculist.h> /* List example */
#include <urcu/compiler.h> /* For CAA_ARRAY_SIZE */
* 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
* 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.
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
* 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);
}
/*
* 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);
* 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;
}
#include <stdint.h>
#include <inttypes.h>
-#include <urcu-qsbr.h> /* QSBR RCU flavor */
+#include <urcu/urcu-qsbr.h> /* QSBR RCU flavor */
#include <urcu/rculist.h> /* List example */
#include <urcu/compiler.h> /* For CAA_ARRAY_SIZE */
* 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
* 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);
}
/*
* 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
* 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;
}
#include <stdint.h>
#include <inttypes.h>
-#define RCU_SIGNAL /* Signal-based RCU flavor */
-#include <urcu.h>
+#include <urcu/urcu-signal.h> /* Signal-based RCU flavor */
#include <urcu/rculist.h> /* List example */
#include <urcu/compiler.h> /* For CAA_ARRAY_SIZE */
* 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
* 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.
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
* 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);
}
/*
* 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);
* 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;
}