X-Git-Url: http://git.liburcu.org/?p=urcu.git;a=blobdiff_plain;f=test_qsbr.c;h=97b918d2dde75b962e9533e6fbbf8fe0d371c69c;hp=af5ccfd58317d06d5c1e2d6c37ac0f268b0c5e16;hb=538d7df5086144837beb7a9c1e2a94eb637b9904;hpb=2a7ac59da1436b86d7cb59fb8b5712c7d98c1519 diff --git a/test_qsbr.c b/test_qsbr.c index af5ccfd..97b918d 100644 --- a/test_qsbr.c +++ b/test_qsbr.c @@ -92,22 +92,33 @@ static unsigned int cpu_affinities[NR_CPUS]; static unsigned int next_aff = 0; static int use_affinity = 0; +pthread_mutex_t affinity_mutex = PTHREAD_MUTEX_INITIALIZER; + static void set_affinity(void) { cpu_set_t mask; int cpu; + int ret; if (!use_affinity) return; + ret = pthread_mutex_lock(&affinity_mutex); + if (ret) { + perror("Error in pthread mutex lock"); + exit(-1); + } cpu = cpu_affinities[next_aff++]; + ret = pthread_mutex_unlock(&affinity_mutex); + if (ret) { + perror("Error in pthread mutex unlock"); + exit(-1); + } CPU_ZERO(&mask); CPU_SET(cpu, &mask); sched_setaffinity(0, sizeof(mask), &mask); } - - /* * returns 0 if test should end. */ @@ -246,13 +257,8 @@ void *thr_writer(void *_count) for (;;) { new = test_array_alloc(); - rcu_copy_mutex_lock(); - old = test_rcu_pointer; - if (old) - assert(old->a == 8); new->a = 8; old = _rcu_publish_content(&test_rcu_pointer, new); - rcu_copy_mutex_unlock(); /* can be done after unlock */ if (old) old->a = 0;