projects
/
urcu.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Update to version 0.4.1
[urcu.git]
/
tests
/
test_urcu.c
diff --git
a/tests/test_urcu.c
b/tests/test_urcu.c
index 8d090ebdd070ab0fb3e64c010d91675365d48861..0cde0b3c992aa039500546934cd8c2be63677720 100644
(file)
--- a/
tests/test_urcu.c
+++ b/
tests/test_urcu.c
@@
-21,6
+21,7
@@
*/
#define _GNU_SOURCE
*/
#define _GNU_SOURCE
+#include "../config.h"
#include <stdio.h>
#include <pthread.h>
#include <stdlib.h>
#include <stdio.h>
#include <pthread.h>
#include <stdlib.h>
@@
-32,12
+33,10
@@
#include <assert.h>
#include <sys/syscall.h>
#include <sched.h>
#include <assert.h>
#include <sys/syscall.h>
#include <sched.h>
+#include <errno.h>
#include <urcu/arch.h>
#include <urcu/arch.h>
-/* Make this big enough to include the POWER5+ L3 cacheline size of 256B */
-#define CACHE_LINE_SIZE 4096
-
/* hardcoded number of CPUs */
#define NR_CPUS 16384
/* hardcoded number of CPUs */
#define NR_CPUS 16384
@@
-98,6
+97,12
@@
static int use_affinity = 0;
pthread_mutex_t affinity_mutex = PTHREAD_MUTEX_INITIALIZER;
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;
static void set_affinity(void)
{
cpu_set_t mask;
@@
-107,6
+112,7
@@
static void set_affinity(void)
if (!use_affinity)
return;
if (!use_affinity)
return;
+#if HAVE_SCHED_SETAFFINITY
ret = pthread_mutex_lock(&affinity_mutex);
if (ret) {
perror("Error in pthread mutex lock");
ret = pthread_mutex_lock(&affinity_mutex);
if (ret) {
perror("Error in pthread mutex lock");
@@
-118,9
+124,15
@@
static void set_affinity(void)
perror("Error in pthread mutex unlock");
exit(-1);
}
perror("Error in pthread mutex unlock");
exit(-1);
}
+
CPU_ZERO(&mask);
CPU_SET(cpu, &mask);
CPU_ZERO(&mask);
CPU_SET(cpu, &mask);
+#if SCHED_SETAFFINITY_ARGS == 2
+ sched_setaffinity(0, &mask);
+#else
sched_setaffinity(0, sizeof(mask), &mask);
sched_setaffinity(0, sizeof(mask), &mask);
+#endif
+#endif /* HAVE_SCHED_SETAFFINITY */
}
/*
}
/*
@@
-259,7
+271,8
@@
void *thr_writer(void *_count)
for (;;) {
new = test_array_alloc();
new->a = 8;
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();
if (old)
old->a = 0;
test_array_free(old);
if (old)
old->a = 0;
test_array_free(old);
This page took
0.024842 seconds
and
4
git commands to generate.