test_urcu_hash*: initialize TLS seeds
[urcu.git] / tests / test_urcu_hash_rw.c
index b6290e9c38235c2e8b43d7291dd8d9573ce19af9..8802b9cd0a621d1d07fee0f4e7bfe368f0a287b6 100644 (file)
@@ -65,9 +65,10 @@ void *test_hash_rw_thr_reader(void *_count)
        struct lfht_test_node *node;
        struct cds_lfht_iter iter;
 
-       printf_verbose("thread_begin %s, thread id : %lx, tid %lu\n",
-                       "reader", (unsigned long) pthread_self(),
-                       (unsigned long) gettid());
+       printf_verbose("thread_begin %s, tid %lu\n",
+                       "reader", urcu_get_thread_id());
+
+       URCU_TLS(rand_lookup) = urcu_get_thread_id() ^ time(NULL);
 
        set_affinity();
 
@@ -107,11 +108,11 @@ void *test_hash_rw_thr_reader(void *_count)
        rcu_unregister_thread();
 
        *count = URCU_TLS(nr_reads);
-       printf_verbose("thread_end %s, thread id : %lx, tid %lu\n",
-                       "reader", (unsigned long) pthread_self(),
-                       (unsigned long) gettid());
-       printf_verbose("readid : %lx, lookupfail %lu, lookupok %lu\n",
-                       (unsigned long) pthread_self(), URCU_TLS(lookup_fail),
+       printf_verbose("thread_end %s, tid %lu\n",
+                       "reader", urcu_get_thread_id());
+       printf_verbose("read tid : %lx, lookupfail %lu, lookupok %lu\n",
+                       urcu_get_thread_id(),
+                       URCU_TLS(lookup_fail),
                        URCU_TLS(lookup_ok));
        return ((void*)1);
 
@@ -125,9 +126,10 @@ void *test_hash_rw_thr_writer(void *_count)
        struct wr_count *count = _count;
        int ret;
 
-       printf_verbose("thread_begin %s, thread id : %lx, tid %lu\n",
-                       "writer", (unsigned long) pthread_self(),
-                       (unsigned long) gettid());
+       printf_verbose("thread_begin %s, tid %lu\n",
+                       "writer", urcu_get_thread_id());
+
+       URCU_TLS(rand_lookup) = urcu_get_thread_id() ^ time(NULL);
 
        set_affinity();
 
@@ -211,12 +213,13 @@ void *test_hash_rw_thr_writer(void *_count)
 
        rcu_unregister_thread();
 
-       printf_verbose("thread_end %s, thread id : %lx, tid %lu\n",
-                       "writer", (unsigned long) pthread_self(),
-                       (unsigned long) gettid());
-       printf_verbose("info id %lx: nr_add %lu, nr_addexist %lu, nr_del %lu, "
-                       "nr_delnoent %lu\n", (unsigned long) pthread_self(), URCU_TLS(nr_add),
-                       URCU_TLS(nr_addexist), URCU_TLS(nr_del),
+       printf_verbose("thread_end %s, tid %lu\n",
+                       "writer", urcu_get_thread_id());
+       printf_verbose("info tid %lu: nr_add %lu, nr_addexist %lu, nr_del %lu, "
+                       "nr_delnoent %lu\n", urcu_get_thread_id(),
+                       URCU_TLS(nr_add),
+                       URCU_TLS(nr_addexist),
+                       URCU_TLS(nr_del),
                        URCU_TLS(nr_delnoent));
        count->update_ops = URCU_TLS(nr_writes);
        count->add = URCU_TLS(nr_add);
@@ -235,6 +238,8 @@ int test_hash_rw_populate_hash(void)
 
        printf("Starting rw test\n");
 
+       URCU_TLS(rand_lookup) = urcu_get_thread_id() ^ time(NULL);
+
        if ((add_unique || add_replace) && init_populate * 10 > init_pool_size) {
                printf("WARNING: required to populate %lu nodes (-k), but random "
 "pool is quite small (%lu values) and we are in add_unique (-u) or add_replace (-s) mode. Try with a "
This page took 0.023115 seconds and 4 git commands to generate.