#include <unistd.h>
#include <stdio.h>
#include <assert.h>
-#include <sys/syscall.h>
#include <sched.h>
#include <errno.h>
#include <urcu/arch.h>
+#ifdef __linux__
+#include <syscall.h>
+#endif
+
/* hardcoded number of CPUs */
#define NR_CPUS 16384
#define _LGPL_SOURCE
#endif
#include <urcu.h>
-#include <urcu/rculfstack.h>
+#include <urcu/cds.h>
#include <urcu-defer.h>
static volatile int test_go, test_stop;
static inline void loop_sleep(unsigned long l)
{
while(l-- != 0)
- cpu_relax();
+ caa_cpu_relax();
}
static int verbose_mode;
static unsigned int nr_enqueuers;
static unsigned int nr_dequeuers;
-static struct rcu_lfs_stack s;
+static struct cds_lfs_stack_rcu s;
void *thr_enqueuer(void *_count)
{
while (!test_go)
{
}
- smp_mb();
+ cmm_smp_mb();
for (;;) {
- struct rcu_lfs_node *node = malloc(sizeof(*node));
+ struct cds_lfs_node_rcu *node = malloc(sizeof(*node));
if (!node)
goto fail;
- rcu_lfs_node_init(node);
- rcu_lfs_push(&s, node);
+ cds_lfs_node_init_rcu(node);
+ /* No rcu read-side is needed for push */
+ cds_lfs_push_rcu(&s, node);
nr_successful_enqueues++;
if (unlikely(wdelay))
void *thr_dequeuer(void *_count)
{
unsigned long long *count = _count;
+ int ret;
printf_verbose("thread_begin %s, thread id : %lx, tid %lu\n",
"dequeuer", pthread_self(), (unsigned long)gettid());
set_affinity();
- rcu_defer_register_thread();
+ ret = rcu_defer_register_thread();
+ if (ret) {
+ printf("Error in rcu_defer_register_thread\n");
+ exit(-1);
+ }
rcu_register_thread();
while (!test_go)
{
}
- smp_mb();
+ cmm_smp_mb();
for (;;) {
- struct rcu_lfs_node *node = rcu_lfs_pop(&s);
+ struct cds_lfs_node_rcu *node;
+ rcu_read_lock();
+ node = cds_lfs_pop_rcu(&s);
+ rcu_read_unlock();
if (node) {
defer_rcu(free, node);
nr_successful_dequeues++;
}
-
nr_dequeues++;
if (unlikely(!test_duration_dequeue()))
break;
return ((void*)2);
}
-void test_end(struct rcu_lfs_stack *s, unsigned long long *nr_dequeues)
+void test_end(struct cds_lfs_stack_rcu *s, unsigned long long *nr_dequeues)
{
- struct rcu_lfs_node *node;
+ struct cds_lfs_node_rcu *node;
do {
- node = rcu_lfs_pop(s);
+ node = cds_lfs_pop_rcu(s);
if (node) {
free(node);
(*nr_dequeues)++;
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);
- rcu_lfs_init(&s);
+ cds_lfs_init_rcu(&s);
next_aff = 0;
exit(1);
}
- smp_mb();
+ cmm_smp_mb();
test_go = 1;