X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=tests%2Ftest_qsbr.c;h=7a68ae836af6a1d7e045da7c476f6d7f6e807cb2;hb=d8540fc53386cd7ff270085aca621e32772832ba;hp=43797716bcaff18fc1a8c9d6eb2fffe2bc3d6e95;hpb=7ac06cef7a7d9394332837edc5c0e9595286a5fc;p=urcu.git diff --git a/tests/test_qsbr.c b/tests/test_qsbr.c index 4379771..7a68ae8 100644 --- a/tests/test_qsbr.c +++ b/tests/test_qsbr.c @@ -21,6 +21,7 @@ */ #define _GNU_SOURCE +#include "../config.h" #include #include #include @@ -32,11 +33,9 @@ #include #include #include +#include -#include "../arch.h" - -/* Make this big enough to include the POWER5+ L3 cacheline size of 256B */ -#define CACHE_LINE_SIZE 4096 +#include /* hardcoded number of CPUs */ #define NR_CPUS 16384 @@ -61,7 +60,7 @@ static inline pid_t gettid(void) #else #define debug_yield_read() #endif -#include "../urcu-qsbr.h" +#include "urcu-qsbr.h" struct test_array { int a; @@ -98,6 +97,12 @@ static int use_affinity = 0; pthread_mutex_t affinity_mutex = PTHREAD_MUTEX_INITIALIZER; +#ifndef HAVE_CPU_SET_T +typedef unsigned long cpu_set_t; +# define CPU_ZERO(cpuset) do { *(cpuset) = 0; } while(0) +# define CPU_SET(cpu, cpuset) do { *(cpuset) |= (1UL << (cpu)); } while(0) +#endif + static void set_affinity(void) { cpu_set_t mask; @@ -107,6 +112,7 @@ static void set_affinity(void) if (!use_affinity) return; +#if HAVE_SCHED_SETAFFINITY ret = pthread_mutex_lock(&affinity_mutex); if (ret) { perror("Error in pthread mutex lock"); @@ -120,7 +126,12 @@ static void set_affinity(void) } CPU_ZERO(&mask); CPU_SET(cpu, &mask); +#if SCHED_SETAFFINITY_ARGS == 2 + sched_setaffinity(0, &mask); +#else sched_setaffinity(0, sizeof(mask), &mask); +#endif +#endif /* HAVE_SCHED_SETAFFINITY */ } /* @@ -262,7 +273,8 @@ void *thr_writer(void *_count) for (;;) { new = test_array_alloc(); new->a = 8; - old = rcu_publish_content(&test_rcu_pointer, new); + old = rcu_xchg_pointer(&test_rcu_pointer, new); + synchronize_rcu(); /* can be done after unlock */ if (old) old->a = 0;