diff -urN orig_0102/userspace-rcu-0.10.2/doc/examples/rculfhash/cds_lfht_destroy.c userspace-rcu-0.10.2/doc/examples/rculfhash/cds_lfht_destroy.c --- orig_0102/userspace-rcu-0.10.2/doc/examples/rculfhash/cds_lfht_destroy.c 2018-12-21 08:44:46.000000000 +0800 +++ userspace-rcu-0.10.2/doc/examples/rculfhash/cds_lfht_destroy.c 2019-07-12 15:11:38.270598030 +0800 @@ -18,7 +18,7 @@ #include #include #include - +#include #include /* RCU flavor */ #include /* RCU Lock-free hash table */ #include /* For CAA_ARRAY_SIZE */ @@ -43,9 +43,9 @@ int main(int argc, char **argv) { - int values[] = { -5, 42, 42, 36, 24, }; /* 42 is duplicated */ + int values[512]; /* 42 is duplicated */ struct cds_lfht *ht; /* Hash table */ - unsigned int i; + unsigned int i,j; int ret = 0; uint32_t seed; struct cds_lfht_iter iter; /* For iteration on hash table */ @@ -56,8 +56,12 @@ * Each thread need using RCU read-side need to be explicitly * registered. */ + for (i = 0; i< 512;i++) { + values[i] = i; + } rcu_register_thread(); + for (j =0;j < 200000; j++) { /* Use time as seed for hash table hashing. */ seed = (uint32_t) time(NULL); @@ -98,6 +102,7 @@ rcu_read_lock(); cds_lfht_add(ht, hash, &node->node); rcu_read_unlock(); + //usleep(500); } /* @@ -105,33 +110,33 @@ * random order, depending on the hash seed. Iteration needs to * be performed within RCU read-side critical section. */ - printf("hash table content (random order):"); + //printf("hash table content (random order):"); rcu_read_lock(); cds_lfht_for_each_entry(ht, &iter, node, node) { - printf(" %d", node->value); + //printf(" %d", node->value); } rcu_read_unlock(); - printf("\n"); + //printf("\n"); /* * Make sure all hash table nodes are removed before destroying. */ - printf("removing all nodes:"); + //printf("removing all nodes:"); rcu_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); - printf(" %d", node->value); + //printf(" %d", node->value); if (ret) { printf(" (concurrently deleted)"); } else { call_rcu(&node->rcu_head, free_node); } + //usleep(500); } rcu_read_unlock(); - printf("\n"); - + //printf("current time: %d\n",j); /* * cds_lfht_destroy() must be called from a very specific * context: it needs to be called from a registered RCU reader @@ -143,7 +148,14 @@ if (ret) { printf("Destroying hash table failed\n"); } + if (j%5000 == 0) { + printf("repeat %d times\n",j); + } + } end: + if (j != 99999) { + printf("only repeat %d times\n",j); + } rcu_unregister_thread(); return ret; } diff -urN orig_0102/userspace-rcu-0.10.2/doc/examples/rculfhash/Makefile.cds_lfht_destroy userspace-rcu-0.10.2/doc/examples/rculfhash/Makefile.cds_lfht_destroy --- orig_0102/userspace-rcu-0.10.2/doc/examples/rculfhash/Makefile.cds_lfht_destroy 2018-01-24 04:14:53.000000000 +0800 +++ userspace-rcu-0.10.2/doc/examples/rculfhash/Makefile.cds_lfht_destroy 2019-07-04 10:33:38.860003818 +0800 @@ -17,6 +17,10 @@ DEPS = jhash.h OBJECTS = $(EXAMPLE_NAME).o BINARY = $(EXAMPLE_NAME) -LIBS = -lurcu-cds -lurcu +#LIBS = -lurcu-cds -lurcu + +LIBS = -L /usr/lib64/ +LIBS += -lurcu-cds -lurcu-signal +CFLAGS += -D RCU_SIGNAL include ../Makefile.examples.template