projects
/
userspace-rcu.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
tests: Use uatomic for accessing global states
[userspace-rcu.git]
/
tests
/
common
/
api.h
diff --git
a/tests/common/api.h
b/tests/common/api.h
index 3008716606b73182438b4a6bcaac120beafeab50..ec3ce1ef7486251ec0321d0c65d18aa761816af4 100644
(file)
--- a/
tests/common/api.h
+++ b/
tests/common/api.h
@@
-14,6
+14,7
@@
#include <urcu/compiler.h>
#include <urcu/arch.h>
#include <urcu/compiler.h>
#include <urcu/arch.h>
+#include <urcu/uatomic.h>
/*
* Machine parameters.
/*
* Machine parameters.
@@
-102,7
+103,7
@@
static int __smp_thread_id(void)
thread_id_t tid = pthread_self();
for (i = 0; i < NR_THREADS; i++) {
thread_id_t tid = pthread_self();
for (i = 0; i < NR_THREADS; i++) {
- if (
__thread_id_map[i]
== tid) {
+ if (
uatomic_read(&__thread_id_map[i])
== tid) {
long v = i + 1; /* must be non-NULL. */
if (pthread_setspecific(thread_id_key, (void *)v) != 0) {
long v = i + 1; /* must be non-NULL. */
if (pthread_setspecific(thread_id_key, (void *)v) != 0) {
@@
-151,12
+152,13
@@
static thread_id_t create_thread(void *(*func)(void *), void *arg)
exit(-1);
}
__thread_id_map[i] = __THREAD_ID_MAP_WAITING;
exit(-1);
}
__thread_id_map[i] = __THREAD_ID_MAP_WAITING;
- spin_unlock(&__thread_id_map_mutex);
+
if (pthread_create(&tid, NULL, func, arg) != 0) {
perror("create_thread:pthread_create");
exit(-1);
}
if (pthread_create(&tid, NULL, func, arg) != 0) {
perror("create_thread:pthread_create");
exit(-1);
}
- __thread_id_map[i] = tid;
+ uatomic_set(&__thread_id_map[i], tid);
+ spin_unlock(&__thread_id_map_mutex);
return tid;
}
return tid;
}
@@
-166,7
+168,7
@@
static void *wait_thread(thread_id_t tid)
void *vp;
for (i = 0; i < NR_THREADS; i++) {
void *vp;
for (i = 0; i < NR_THREADS; i++) {
- if (
__thread_id_map[i]
== tid)
+ if (
uatomic_read(&__thread_id_map[i])
== tid)
break;
}
if (i >= NR_THREADS){
break;
}
if (i >= NR_THREADS){
@@
-178,7
+180,7
@@
static void *wait_thread(thread_id_t tid)
perror("wait_thread:pthread_join");
exit(-1);
}
perror("wait_thread:pthread_join");
exit(-1);
}
-
__thread_id_map[i] = __THREAD_ID_MAP_EMPTY
;
+
uatomic_set(&__thread_id_map[i], __THREAD_ID_MAP_EMPTY)
;
return vp;
}
return vp;
}
This page took
0.024223 seconds
and
4
git commands to generate.