projects
/
urcu.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
URCU : use pthread_equal()
[urcu.git]
/
test_urcu.c
diff --git
a/test_urcu.c
b/test_urcu.c
index 650c030efece587c4eed2a47fb2fb67aa9fc3eb7..db0b68ca2d18cc58cc0bd163a938375773ec660c 100644
(file)
--- a/
test_urcu.c
+++ b/
test_urcu.c
@@
-1,3
+1,13
@@
+/*
+ * test_urcu.c
+ *
+ * Userspace RCU library - test program
+ *
+ * Copyright February 2009 - Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
+ *
+ * Distributed under GPLv2
+ */
+
#include <stdio.h>
#include <pthread.h>
#include <stdlib.h>
#include <stdio.h>
#include <pthread.h>
#include <stdlib.h>
@@
-27,12
+37,12
@@
void *thr_reader(void *arg)
struct test_array *local_ptr;
printf("thread %s, thread id : %lu, pid %lu\n",
struct test_array *local_ptr;
printf("thread %s, thread id : %lu, pid %lu\n",
- "reader", pthread_self(), getpid());
+ "reader", pthread_self(),
(unsigned long)
getpid());
sleep(2);
urcu_register_thread();
sleep(2);
urcu_register_thread();
- for (i = 0; i < 1000; i++) {
+ for (i = 0; i < 1000
00
; i++) {
for (j = 0; j < 100000000; j++) {
qparity = rcu_read_lock();
local_ptr = rcu_dereference(test_rcu_pointer);
for (j = 0; j < 100000000; j++) {
qparity = rcu_read_lock();
local_ptr = rcu_dereference(test_rcu_pointer);
@@
-57,22
+67,22
@@
void *thr_writer(void *arg)
struct test_array *new, *old;
printf("thread %s, thread id : %lu, pid %lu\n",
struct test_array *new, *old;
printf("thread %s, thread id : %lu, pid %lu\n",
- "writer", pthread_self(), getpid());
+ "writer", pthread_self(),
(unsigned long)
getpid());
sleep(2);
sleep(2);
- for (i = 0; i < 100000; i++) {
- rcu_write_lock();
+ for (i = 0; i < 10000000; i++) {
new = malloc(sizeof(struct test_array));
new = malloc(sizeof(struct test_array));
+ rcu_write_lock();
old = test_rcu_pointer;
if (old) {
assert(old->a == 8);
assert(old->b == 12);
assert(old->c[55] == 2);
}
old = test_rcu_pointer;
if (old) {
assert(old->a == 8);
assert(old->b == 12);
assert(old->c[55] == 2);
}
- new->a = 8;
- new->b = 12;
new->c[55] = 2;
new->c[55] = 2;
- old = urcu_publish_content(&test_rcu_pointer, new);
+ new->b = 12;
+ new->a = 8;
+ old = urcu_publish_content((void **)&test_rcu_pointer, new);
rcu_write_unlock();
/* can be done after unlock */
if (old) {
rcu_write_unlock();
/* can be done after unlock */
if (old) {
This page took
0.023899 seconds
and
4
git commands to generate.