X-Git-Url: http://git.liburcu.org/?p=userspace-rcu.git;a=blobdiff_plain;f=tests%2Ftest_urcu_lfs.c;h=5c350eb470adf8c7e2348dc05c2fe765628ca4c8;hp=88bf65d09bd533bf19139a4028e68e990e43ea64;hb=f90535ef41a3ddef0c8bcd76a6ecb89f3fd09fc3;hpb=bd252a04bbbb163aa4d8864b1e1e5a3a4d9d0892 diff --git a/tests/test_urcu_lfs.c b/tests/test_urcu_lfs.c index 88bf65d..5c350eb 100644 --- a/tests/test_urcu_lfs.c +++ b/tests/test_urcu_lfs.c @@ -34,11 +34,11 @@ #include #include #include -#include #include #include #include +#include "cpuset.h" #ifdef __linux__ #include @@ -98,12 +98,6 @@ 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; @@ -170,7 +164,8 @@ void *thr_enqueuer(void *_count) unsigned long long *count = _count; printf_verbose("thread_begin %s, thread id : %lx, tid %lu\n", - "enqueuer", pthread_self(), (unsigned long)gettid()); + "enqueuer", (unsigned long) pthread_self(), + (unsigned long) gettid()); set_affinity(); @@ -204,7 +199,8 @@ fail: count[1] = URCU_TLS(nr_successful_enqueues); printf_verbose("enqueuer thread_end, thread id : %lx, tid %lu, " "enqueues %llu successful_enqueues %llu\n", - pthread_self(), (unsigned long)gettid(), + (unsigned long) pthread_self(), + (unsigned long) gettid(), URCU_TLS(nr_enqueues), URCU_TLS(nr_successful_enqueues)); return ((void*)1); @@ -224,7 +220,8 @@ void *thr_dequeuer(void *_count) int ret; printf_verbose("thread_begin %s, thread id : %lx, tid %lu\n", - "dequeuer", pthread_self(), (unsigned long)gettid()); + "dequeuer", (unsigned long) pthread_self(), + (unsigned long) gettid()); set_affinity(); @@ -264,7 +261,8 @@ void *thr_dequeuer(void *_count) printf_verbose("dequeuer thread_end, thread id : %lx, tid %lu, " "dequeues %llu, successful_dequeues %llu\n", - pthread_self(), (unsigned long)gettid(), + (unsigned long) pthread_self(), + (unsigned long) gettid(), URCU_TLS(nr_dequeues), URCU_TLS(nr_successful_dequeues)); count[0] = URCU_TLS(nr_dequeues); count[1] = URCU_TLS(nr_successful_dequeues); @@ -372,13 +370,15 @@ int main(int argc, char **argv) printf_verbose("Writer delay : %lu loops.\n", rduration); printf_verbose("Reader duration : %lu loops.\n", wdelay); printf_verbose("thread %-6s, thread id : %lx, tid %lu\n", - "main", pthread_self(), (unsigned long)gettid()); + "main", (unsigned long) pthread_self(), + (unsigned long) gettid()); - tid_enqueuer = malloc(sizeof(*tid_enqueuer) * nr_enqueuers); - tid_dequeuer = malloc(sizeof(*tid_dequeuer) * nr_dequeuers); - count_enqueuer = malloc(2 * sizeof(*count_enqueuer) * nr_enqueuers); - count_dequeuer = malloc(2 * sizeof(*count_dequeuer) * nr_dequeuers); + tid_enqueuer = calloc(nr_enqueuers, sizeof(*tid_enqueuer)); + tid_dequeuer = calloc(nr_dequeuers, sizeof(*tid_dequeuer)); + count_enqueuer = calloc(nr_enqueuers, 2 * sizeof(*count_enqueuer)); + count_dequeuer = calloc(nr_dequeuers, 2 * sizeof(*count_dequeuer)); cds_lfs_init_rcu(&s); + err = create_all_cpu_call_rcu_data(0); if (err) { printf("Per-CPU call_rcu() worker threads unavailable. Using default global worker thread.\n");