X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=tests%2Fbenchmark%2Ftest_urcu_assign.c;h=758165eff5340de772761c7c4928902774bd0f1c;hb=e3717dbc8700ef1db5d341e2c5a74f61c4981ab3;hp=fe34af3971a29322f78fb3c9c43de3310e2d1b73;hpb=6893800a4d1cc14dff0395ddcd660a5138db183d;p=urcu.git diff --git a/tests/benchmark/test_urcu_assign.c b/tests/benchmark/test_urcu_assign.c index fe34af3..758165e 100644 --- a/tests/benchmark/test_urcu_assign.c +++ b/tests/benchmark/test_urcu_assign.c @@ -137,6 +137,7 @@ static unsigned int nr_writers; pthread_mutex_t rcu_copy_mutex = PTHREAD_MUTEX_INITIALIZER; +static void rcu_copy_mutex_lock(void) { int ret; @@ -147,6 +148,7 @@ void rcu_copy_mutex_lock(void) } } +static void rcu_copy_mutex_unlock(void) { int ret; @@ -165,8 +167,8 @@ void rcu_copy_mutex_unlock(void) * both alloc and free, which insures we never run over our tail. */ #define ARRAY_SIZE (1048576 * nr_writers) -#define ARRAY_POISON 0xDEADBEEF -static int array_index; +#define ARRAY_POISON (int) 0xDEADBEEF +static unsigned int array_index; static struct test_array *test_array; static struct test_array *test_array_alloc(void) @@ -191,6 +193,7 @@ static void test_array_free(struct test_array *ptr) ptr->a = ARRAY_POISON; } +static void *thr_reader(void *_count) { unsigned long long *count = _count; @@ -231,6 +234,7 @@ void *thr_reader(void *_count) } +static void *thr_writer(void *_count) { unsigned long long *count = _count; @@ -272,6 +276,7 @@ void *thr_writer(void *_count) return ((void*)2); } +static void show_usage(int argc, char **argv) { printf("Usage : %s nr_readers nr_writers duration (s) \n", @@ -294,6 +299,7 @@ int main(int argc, char **argv) unsigned long long *count_reader, *count_writer; unsigned long long tot_reads = 0, tot_writes = 0; int i, a; + unsigned int i_thr; if (argc < 4) { show_usage(argc, argv); @@ -311,7 +317,7 @@ int main(int argc, char **argv) show_usage(argc, argv); return -1; } - + err = sscanf(argv[3], "%lu", &duration); if (err != 1) { show_usage(argc, argv); @@ -380,15 +386,15 @@ int main(int argc, char **argv) next_aff = 0; - for (i = 0; i < nr_readers; i++) { - err = pthread_create(&tid_reader[i], NULL, thr_reader, - &count_reader[i]); + for (i_thr = 0; i_thr < nr_readers; i_thr++) { + err = pthread_create(&tid_reader[i_thr], NULL, thr_reader, + &count_reader[i_thr]); if (err != 0) exit(1); } - for (i = 0; i < nr_writers; i++) { - err = pthread_create(&tid_writer[i], NULL, thr_writer, - &count_writer[i]); + for (i_thr = 0; i_thr < nr_writers; i_thr++) { + err = pthread_create(&tid_writer[i_thr], NULL, thr_writer, + &count_writer[i_thr]); if (err != 0) exit(1); } @@ -401,19 +407,19 @@ int main(int argc, char **argv) test_stop = 1; - for (i = 0; i < nr_readers; i++) { - err = pthread_join(tid_reader[i], &tret); + for (i_thr = 0; i_thr < nr_readers; i_thr++) { + err = pthread_join(tid_reader[i_thr], &tret); if (err != 0) exit(1); - tot_reads += count_reader[i]; + tot_reads += count_reader[i_thr]; } - for (i = 0; i < nr_writers; i++) { - err = pthread_join(tid_writer[i], &tret); + for (i_thr = 0; i_thr < nr_writers; i_thr++) { + err = pthread_join(tid_writer[i_thr], &tret); if (err != 0) exit(1); - tot_writes += count_writer[i]; + tot_writes += count_writer[i_thr]; } - + printf_verbose("total number of reads : %llu, writes %llu\n", tot_reads, tot_writes); printf("SUMMARY %-25s testdur %4lu nr_readers %3u rdur %6lu wdur %6lu " @@ -422,11 +428,13 @@ int main(int argc, char **argv) argv[0], duration, nr_readers, rduration, wduration, nr_writers, wdelay, tot_reads, tot_writes, tot_reads + tot_writes); + test_array_free(test_rcu_pointer); free(test_array); free(tid_reader); free(tid_writer); free(count_reader); free(count_writer); + return 0; }