*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
/* write-side C.S. duration, in loops */
static unsigned long wduration;
/* write-side C.S. duration, in loops */
static unsigned long wduration;
-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);
/*
* malloc/free are reusing memory areas too quickly, which does not let us
* test races appropriately. Use a large circular array for allocations.
/*
* malloc/free are reusing memory areas too quickly, which does not let us
* test races appropriately. Use a large circular array for allocations.
- * ARRAY_SIZE is larger than nr_writers, which insures we never run over our tail.
+ * ARRAY_SIZE is larger than nr_writers, and we keep the mutex across
+ * both alloc and free, which insures we never run over our tail.
index = array_index % ARRAY_SIZE;
assert(test_array[index].a == ARRAY_POISON ||
test_array[index].a == 0);
index = array_index % ARRAY_SIZE;
assert(test_array[index].a == ARRAY_POISON ||
test_array[index].a == 0);
printf_verbose("thread_end %s, thread id : %lx, tid %lu\n",
"reader", pthread_self(), (unsigned long)gettid());
return ((void*)1);
printf_verbose("thread_end %s, thread id : %lx, tid %lu\n",
"reader", pthread_self(), (unsigned long)gettid());
return ((void*)1);
new = test_array_alloc();
new->a = 8;
old = rcu_xchg_pointer(&test_rcu_pointer, new);
new = test_array_alloc();
new->a = 8;
old = rcu_xchg_pointer(&test_rcu_pointer, new);
loop_sleep(wdelay);
}
printf_verbose("thread_end %s, thread id : %lx, tid %lu\n",
"writer", pthread_self(), (unsigned long)gettid());
loop_sleep(wdelay);
}
printf_verbose("thread_end %s, thread id : %lx, tid %lu\n",
"writer", pthread_self(), (unsigned long)gettid());
printf_verbose("thread %-6s, thread id : %lx, tid %lu\n",
"main", pthread_self(), (unsigned long)gettid());
printf_verbose("thread %-6s, thread id : %lx, tid %lu\n",
"main", pthread_self(), (unsigned long)gettid());
tid_reader = malloc(sizeof(*tid_reader) * nr_readers);
tid_writer = malloc(sizeof(*tid_writer) * nr_writers);
count_reader = malloc(sizeof(*count_reader) * nr_readers);
tid_reader = malloc(sizeof(*tid_reader) * nr_readers);
tid_writer = malloc(sizeof(*tid_writer) * nr_writers);
count_reader = malloc(sizeof(*count_reader) * nr_readers);