rcuja: Use urcu_get_thread_id()
[userspace-rcu.git] / tests / test_urcu_ja_range.c
index 18f36d5f4d9826993b8480c5294dcc17b7651c06..93ac706c40e7d1b6544d04588f6404471e02a734 100644 (file)
@@ -197,8 +197,10 @@ void *test_ja_rw_thr_reader(void *_count)
        struct cds_ja_range *range;
        uint64_t key;
 
-       printf_verbose("thread_begin %s, thread id : %lx, tid %lu\n",
-                       "reader", pthread_self(), (unsigned long) gettid());
+       printf_verbose("thread_begin %s, tid %lu\n",
+                       "reader", urcu_get_thread_id());
+
+       URCU_TLS(rand_lookup) = (unsigned int) urcu_get_thread_id() ^ time(NULL);
 
        set_affinity();
 
@@ -212,9 +214,11 @@ void *test_ja_rw_thr_reader(void *_count)
        for (;;) {
                rcu_read_lock();
 
-               /* note: only looking up ulong keys */
-               key = ((unsigned long) rand_r(&URCU_TLS(rand_lookup)) % lookup_pool_size) + lookup_pool_offset;
+               key = (uint64_t) rand_r(&URCU_TLS(rand_lookup));
+               key += (uint64_t) rand_r(&URCU_TLS(rand_lookup)) << 32ULL;
+               key = (key % lookup_pool_size) + lookup_pool_offset;
                key *= key_mul;
+
                range = cds_ja_range_lookup(test_ja, key);
                if (!range) {
                        if (validate_lookup) {
@@ -248,10 +252,10 @@ void *test_ja_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", pthread_self(), (unsigned long) gettid());
-       printf_verbose("readid : %lx, lookupfail %lu, lookupok %lu\n",
-                       pthread_self(), URCU_TLS(lookup_fail),
+       printf_verbose("thread_end %s, tid %lu\n",
+                       "reader", urcu_get_thread_id());
+       printf_verbose("read tid : %lu, lookupfail %lu, lookupok %lu\n",
+                       urcu_get_thread_id(), URCU_TLS(lookup_fail),
                        URCU_TLS(lookup_ok));
        return ((void*)1);
 }
@@ -268,8 +272,10 @@ void *test_ja_rw_thr_writer(void *_count)
        struct wr_count *count = _count;
        int ret;
 
-       printf_verbose("thread_begin %s, thread id : %lx, tid %lu\n",
-                       "writer", pthread_self(), (unsigned long) gettid());
+       printf_verbose("thread_begin %s, tid %lu\n",
+                       "writer", urcu_get_thread_id());
+
+       URCU_TLS(rand_lookup) = (unsigned int) urcu_get_thread_id() ^ time(NULL);
 
        set_affinity();
 
@@ -286,9 +292,14 @@ void *test_ja_rw_thr_writer(void *_count)
                        struct cds_ja_range *range;
                        uint64_t start, end, tmp;
 
-                       /* note: only inserting ulong keys */
-                       start = ((unsigned long) rand_r(&URCU_TLS(rand_lookup)) % write_pool_size) + write_pool_offset;
-                       end = ((unsigned long) rand_r(&URCU_TLS(rand_lookup)) % write_pool_size) + write_pool_offset;
+                       start = (uint64_t) rand_r(&URCU_TLS(rand_lookup));
+                       start += (uint64_t) rand_r(&URCU_TLS(rand_lookup)) << 32ULL;
+                       start = (start % write_pool_size) + write_pool_offset;
+
+                       end = (uint64_t) rand_r(&URCU_TLS(rand_lookup));
+                       end += (uint64_t) rand_r(&URCU_TLS(rand_lookup)) << 32ULL;
+                       end = (end % write_pool_size) + write_pool_offset;
+
                        start *= key_mul;
                        end *= key_mul;
                        if (start > end) {
@@ -316,8 +327,9 @@ void *test_ja_rw_thr_writer(void *_count)
                        uint64_t key;
 
                        /* May delete */
-                       /* note: only deleting ulong keys */
-                       key = ((unsigned long) rand_r(&URCU_TLS(rand_lookup)) % write_pool_size) + write_pool_offset;
+                       key = (uint64_t) rand_r(&URCU_TLS(rand_lookup));
+                       key += (uint64_t) rand_r(&URCU_TLS(rand_lookup)) << 32ULL;
+                       key = (key % write_pool_size) + write_pool_offset;
                        key *= key_mul;
 
                        rcu_read_lock();
@@ -347,10 +359,11 @@ void *test_ja_rw_thr_writer(void *_count)
 
        rcu_unregister_thread();
 
-       printf_verbose("thread_end %s, thread id : %lx, tid %lu\n",
-                       "writer", pthread_self(), (unsigned long) gettid());
-       printf_verbose("info id %lx: nr_add %lu, nr_addexist %lu, nr_del %lu, "
-                       "nr_delnoent %lu\n", pthread_self(), URCU_TLS(nr_add),
+       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);
@@ -628,8 +641,8 @@ int main(int argc, char **argv)
                printf_verbose("Validating lookups.\n");
        if (leak_detection)
                printf_verbose("Memory leak dection activated.\n");
-       printf_verbose("thread %-6s, thread id : %lx, tid %lu\n",
-                       "main", pthread_self(), (unsigned long)gettid());
+       printf_verbose("thread %-6s, tid %lu\n",
+                       "main", urcu_get_thread_id());
 
        memset(&act, 0, sizeof(act));
        ret = sigemptyset(&act.sa_mask);
This page took 0.027152 seconds and 4 git commands to generate.