X-Git-Url: https://git.liburcu.org/?p=urcu.git;a=blobdiff_plain;f=tests%2Ftest_urcu_qsbr_gc.c;h=f8cf784ccd2a455c1afce76ec7dc7449cb671412;hp=9deb0aa2044c1e8ec34d3f8a3736f90668b2c828;hb=95bc7fb90c36ee10dc171a23e8783eff30072b7b;hpb=cc6b0c208a9707f8a64609a51167290caeace288 diff --git a/tests/test_urcu_qsbr_gc.c b/tests/test_urcu_qsbr_gc.c index 9deb0aa..f8cf784 100644 --- a/tests/test_urcu_qsbr_gc.c +++ b/tests/test_urcu_qsbr_gc.c @@ -35,6 +35,7 @@ #include #include +#include #ifdef __linux__ #include @@ -88,9 +89,9 @@ static struct reclaim_queue *pending_reclaims; /* write-side C.S. duration, in loops */ static unsigned long wduration; -static inline void loop_sleep(unsigned long l) +static inline void loop_sleep(unsigned long loops) { - while(l-- != 0) + while (loops-- != 0) caa_cpu_relax(); } @@ -116,9 +117,10 @@ typedef unsigned long cpu_set_t; static void set_affinity(void) { +#if HAVE_SCHED_SETAFFINITY cpu_set_t mask; - int cpu; - int ret; + int cpu, ret; +#endif /* HAVE_SCHED_SETAFFINITY */ if (!use_affinity) return; @@ -159,8 +161,8 @@ static int test_duration_read(void) return !test_stop; } -static unsigned long long __thread nr_writes; -static unsigned long long __thread nr_reads; +static DEFINE_URCU_TLS(unsigned long long, nr_writes); +static DEFINE_URCU_TLS(unsigned long long, nr_reads); static unsigned int nr_readers; static unsigned int nr_writers; @@ -217,9 +219,9 @@ void *thr_reader(void *_count) if (caa_unlikely(rduration)) loop_sleep(rduration); _rcu_read_unlock(); - nr_reads++; + URCU_TLS(nr_reads)++; /* QS each 1024 reads */ - if (caa_unlikely((nr_reads & ((1 << 10) - 1)) == 0)) + if (caa_unlikely((URCU_TLS(nr_reads) & ((1 << 10) - 1)) == 0)) _rcu_quiescent_state(); if (caa_unlikely(!test_duration_read())) break; @@ -227,7 +229,7 @@ void *thr_reader(void *_count) rcu_unregister_thread(); - *count = nr_reads; + *count = URCU_TLS(nr_reads); printf_verbose("thread_end %s, thread id : %lx, tid %lu\n", "reader", pthread_self(), (unsigned long)gettid()); return ((void*)1); @@ -293,7 +295,7 @@ void *thr_writer(void *data) if (caa_unlikely(wduration)) loop_sleep(wduration); rcu_gc_reclaim(wtidx, old); - nr_writes++; + URCU_TLS(nr_writes)++; if (caa_unlikely(!test_duration_write())) break; if (caa_unlikely(wdelay)) @@ -302,7 +304,7 @@ void *thr_writer(void *data) printf_verbose("thread_end %s, thread id : %lx, tid %lu\n", "writer", pthread_self(), (unsigned long)gettid()); - tot_nr_writes[wtidx] = nr_writes; + tot_nr_writes[wtidx] = URCU_TLS(nr_writes); return ((void*)2); }