void *thr_reader(void *_count) { unsigned long long *count = _count; printf_verbose("thread_begin %s, thread id : %lx, tid %lu\n", "reader", (unsigned long) pthread_self(), (unsigned long) gettid()); set_affinity(); while (!test_go) { } for (;;) { pthread_rwlock_rdlock(&lock); assert(test_array.a == 8); if (caa_unlikely(rduration)) loop_sleep(rduration); pthread_rwlock_unlock(&lock); URCU_TLS(nr_reads)++; if (caa_unlikely(!test_duration_read())) break; } *count = URCU_TLS(nr_reads); printf_verbose("thread_end %s, thread id : %lx, tid %lu\n", "reader", (unsigned long) pthread_self(), (unsigned long) gettid()); return ((void*)1); }
void *thr_reader(void *data) { unsigned long tidx = (unsigned long)data; printf_verbose("thread_begin %s, tid %lu\n", "reader", urcu_get_thread_id()); set_affinity(); while (!test_go) { } for (;;) { pthread_mutex_lock(&per_thread_lock[tidx].lock); assert(test_array.a == 8); if (caa_unlikely(rduration)) loop_sleep(rduration); pthread_mutex_unlock(&per_thread_lock[tidx].lock); URCU_TLS(nr_reads)++; if (caa_unlikely(!test_duration_read())) break; } tot_nr_reads[tidx] = URCU_TLS(nr_reads); printf_verbose("thread_end %s, tid %lu\n", "reader", urcu_get_thread_id()); return ((void*)1); }
void *thr_reader(void *data) { unsigned long tidx = (unsigned long)data; printf_verbose("thread_begin %s, thread id : %lx, tid %lu\n", "reader", pthread_self(), (unsigned long)gettid()); set_affinity(); while (!test_go) { } for (;;) { pthread_mutex_lock(&lock); assert(test_array.a == 8); if (unlikely(rduration)) loop_sleep(rduration); pthread_mutex_unlock(&lock); nr_reads++; if (unlikely(!test_duration_read())) break; } tot_nr_reads[tidx] = nr_reads; printf_verbose("thread_end %s, thread id : %lx, tid %lu\n", "reader", pthread_self(), (unsigned long)gettid()); return ((void*)1); }
void *test_hash_rw_thr_reader(void *_count) { unsigned long long *count = _count; struct lfht_test_node *node; struct cds_lfht_iter iter; 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(); rcu_register_thread(); while (!test_go) { } cmm_smp_mb(); for (;;) { rcu_read_lock(); cds_lfht_test_lookup(test_ht, (void *)(((unsigned long) rand_r(&URCU_TLS(rand_lookup)) % lookup_pool_size) + lookup_pool_offset), sizeof(void *), &iter); node = cds_lfht_iter_get_test_node(&iter); if (node == NULL) { if (validate_lookup) { printf("[ERROR] Lookup cannot find initial node.\n"); exit(-1); } URCU_TLS(lookup_fail)++; } else { URCU_TLS(lookup_ok)++; } rcu_debug_yield_read(); if (caa_unlikely(rduration)) loop_sleep(rduration); rcu_read_unlock(); URCU_TLS(nr_reads)++; if (caa_unlikely(!test_duration_read())) break; if (caa_unlikely((URCU_TLS(nr_reads) & ((1 << 10) - 1)) == 0)) rcu_quiescent_state(); } rcu_unregister_thread(); *count = URCU_TLS(nr_reads); 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); }