From: Mathieu Desnoyers Date: Tue, 9 Jun 2009 17:55:00 +0000 (-0400) Subject: Move test start time closer to enable X-Git-Tag: v0.1~186 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=7685d9639221a1dc5c0eeba54a60d633618b242a;p=urcu.git Move test start time closer to enable Signed-off-by: Mathieu Desnoyers --- diff --git a/test_qsbr.c b/test_qsbr.c index a8cb799..3d906cc 100644 --- a/test_qsbr.c +++ b/test_qsbr.c @@ -31,6 +31,8 @@ #include #include +#include "arch.h" + #if defined(_syscall0) _syscall0(pid_t, gettid) #elif defined(__NR_gettid) @@ -166,6 +168,7 @@ void *thr_reader(void *_count) while (!test_go) { } + smp_mb(); for (;;) { _rcu_read_lock(); @@ -201,6 +204,7 @@ void *thr_writer(void *_count) while (!test_go) { } + smp_mb(); for (;;) { new = test_array_alloc(); @@ -234,7 +238,7 @@ void show_usage(int argc, char **argv) #ifdef DEBUG_YIELD printf(" [-r] [-w] (yield reader and/or writer)"); #endif - printf(" [-d delay] (writer period)"); + printf(" [-d delay] (writer period (us))"); printf("\n"); } @@ -295,7 +299,6 @@ int main(int argc, char **argv) printf("running test for %lu seconds, %u readers, %u writers.\n", duration, nr_readers, nr_writers); printf("Writer delay : %u us.\n", wdelay); - start_time = time(NULL); printf("thread %-6s, thread id : %lx, tid %lu\n", "main", pthread_self(), (unsigned long)gettid()); @@ -318,7 +321,9 @@ int main(int argc, char **argv) exit(1); } + start_time = time(NULL); test_go = 1; + smp_mb(); for (i = 0; i < nr_readers; i++) { err = pthread_join(tid_reader[i], &tret); diff --git a/test_rwlock.c b/test_rwlock.c index 9a818ff..b54aed9 100644 --- a/test_rwlock.c +++ b/test_rwlock.c @@ -31,6 +31,8 @@ #include #include +#include "arch.h" + #if defined(_syscall0) _syscall0(pid_t, gettid) #elif defined(__NR_gettid) @@ -160,6 +162,7 @@ void *thr_writer(void *_count) while (!test_go) { } + smp_mb(); for (;;) { pthread_rwlock_wrlock(&lock); @@ -184,7 +187,7 @@ void show_usage(int argc, char **argv) #ifdef DEBUG_YIELD printf(" [-r] [-w] (yield reader and/or writer)"); #endif - printf(" [-d delay] (writer period)"); + printf(" [-d delay] (writer period (us))"); printf("\n"); } @@ -201,6 +204,7 @@ int main(int argc, char **argv) show_usage(argc, argv); return -1; } + smp_mb(); err = sscanf(argv[1], "%u", &nr_readers); if (err != 1) { @@ -245,7 +249,6 @@ int main(int argc, char **argv) printf("running test for %lu seconds, %u readers, %u writers.\n", duration, nr_readers, nr_writers); printf("Writer delay : %u us.\n", wdelay); - start_time = time(NULL); printf("thread %-6s, thread id : %lx, tid %lu\n", "main", pthread_self(), (unsigned long)gettid()); @@ -267,7 +270,9 @@ int main(int argc, char **argv) exit(1); } + start_time = time(NULL); test_go = 1; + smp_mb(); for (i = 0; i < nr_readers; i++) { err = pthread_join(tid_reader[i], &tret); diff --git a/test_urcu.c b/test_urcu.c index 4dfe218..47f6955 100644 --- a/test_urcu.c +++ b/test_urcu.c @@ -31,6 +31,8 @@ #include #include +#include "arch.h" + #if defined(_syscall0) _syscall0(pid_t, gettid) #elif defined(__NR_gettid) @@ -170,6 +172,7 @@ void *thr_reader(void *_count) while (!test_go) { } + smp_mb(); for (;;) { rcu_read_lock(); @@ -203,6 +206,7 @@ void *thr_writer(void *_count) while (!test_go) { } + smp_mb(); for (;;) { new = test_array_alloc(); @@ -236,7 +240,7 @@ void show_usage(int argc, char **argv) #ifdef DEBUG_YIELD printf(" [-r] [-w] (yield reader and/or writer)"); #endif - printf(" [-d delay] (writer period)"); + printf(" [-d delay] (writer period (us))"); printf("\n"); } @@ -285,7 +289,7 @@ int main(int argc, char **argv) break; #endif case 'd': - if (argc < i + 1) { + if (argc < i + 2) { show_usage(argc, argv); return -1; } @@ -297,7 +301,6 @@ int main(int argc, char **argv) printf("running test for %lu seconds, %u readers, %u writers.\n", duration, nr_readers, nr_writers); printf("Writer delay : %u us.\n", wdelay); - start_time = time(NULL); printf("thread %-6s, thread id : %lx, tid %lu\n", "main", pthread_self(), (unsigned long)gettid()); @@ -320,7 +323,9 @@ int main(int argc, char **argv) exit(1); } + start_time = time(NULL); test_go = 1; + smp_mb(); for (i = 0; i < nr_readers; i++) { err = pthread_join(tid_reader[i], &tret);