X-Git-Url: http://git.liburcu.org/?p=urcu.git;a=blobdiff_plain;f=test_urcu.c;h=129b33abdb4a3dd6d2e0bea6f567c0caad2fd611;hp=3a28474561977675c6932663055c3cb8d2e2fc19;hb=5873cd17404d996680e6afc2f11c2a3ee9b354fa;hpb=5791dd3e6fd6d4be9fcacc347b70de17b967ca74 diff --git a/test_urcu.c b/test_urcu.c index 3a28474..129b33a 100644 --- a/test_urcu.c +++ b/test_urcu.c @@ -47,14 +47,25 @@ static struct test_array *test_rcu_pointer; static unsigned long duration; static time_t start_time; static unsigned long __thread duration_interval; -#define DURATION_TEST_DELAY 100 +#define DURATION_TEST_DELAY_WRITE 4 +#define DURATION_TEST_DELAY_READ 100 /* * returns 0 if test should end. */ -static int test_duration(void) +static int test_duration_write(void) { - if (duration_interval++ >= DURATION_TEST_DELAY) { + if (duration_interval++ >= DURATION_TEST_DELAY_WRITE) { + duration_interval = 0; + if (time(NULL) - start_time >= duration) + return 0; + } + return 1; +} + +static int test_duration_read(void) +{ + if (duration_interval++ >= DURATION_TEST_DELAY_READ) { duration_interval = 0; if (time(NULL) - start_time >= duration) return 0; @@ -145,7 +156,7 @@ void *thr_reader(void *_count) assert(local_ptr->a == 8); rcu_read_unlock(); nr_reads++; - if (!test_duration()) + if (!test_duration_read()) break; } @@ -180,7 +191,7 @@ void *thr_writer(void *_count) old->a = 0; test_array_free(old); nr_writes++; - if (!test_duration()) + if (!test_duration_write()) break; if (!no_writer_delay) usleep(1); @@ -270,6 +281,7 @@ int main(int argc, char **argv) exit(1); tot_writes += count_writer[i]; } + printf("total number of reads : %llu, writes %llu\n", tot_reads, tot_writes); test_array_free(test_rcu_pointer);