From: Mathieu Desnoyers Date: Wed, 10 Jun 2009 18:59:13 +0000 (-0400) Subject: Unlikely for tests X-Git-Tag: v0.1~170 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=59d5a40624428364374c306409979155beddfaac;p=urcu.git Unlikely for tests Signed-off-by: Mathieu Desnoyers --- diff --git a/test_perthreadlock.c b/test_perthreadlock.c index 7b6a65c..3684975 100644 --- a/test_perthreadlock.c +++ b/test_perthreadlock.c @@ -134,7 +134,7 @@ void *thr_reader(void *data) assert(test_array.a == 8); pthread_mutex_unlock(&per_thread_lock[tidx].lock); nr_reads++; - if (!test_duration_read()) + if (unlikely(!test_duration_read())) break; } @@ -168,9 +168,9 @@ void *thr_writer(void *data) pthread_mutex_unlock(&per_thread_lock[tidx].lock); } nr_writes++; - if (!test_duration_write()) + if (unlikely(!test_duration_write())) break; - if (wdelay) + if (unlikely(wdelay)) usleep(wdelay); } diff --git a/test_qsbr.c b/test_qsbr.c index ff55f8b..82521ef 100644 --- a/test_qsbr.c +++ b/test_qsbr.c @@ -165,9 +165,9 @@ void *thr_reader(void *_count) _rcu_read_unlock(); nr_reads++; /* QS each 1024 reads */ - if ((nr_reads & ((1 << 10) - 1)) == 0) + if (unlikely((nr_reads & ((1 << 10) - 1)) == 0)) _rcu_quiescent_state(); - if (!test_duration_read()) + if (unlikely(!test_duration_read())) break; } @@ -207,9 +207,9 @@ void *thr_writer(void *_count) old->a = 0; test_array_free(old); nr_writes++; - if (!test_duration_write()) + if (unlikely(!test_duration_write())) break; - if (wdelay) + if (unlikely(wdelay)) usleep(wdelay); } diff --git a/test_rwlock.c b/test_rwlock.c index ef3ce2c..1c29d73 100644 --- a/test_rwlock.c +++ b/test_rwlock.c @@ -127,7 +127,7 @@ void *thr_reader(void *_count) assert(test_array.a == 8); pthread_rwlock_unlock(&lock); nr_reads++; - if (!test_duration_read()) + if (unlikely(!test_duration_read())) break; } @@ -156,9 +156,9 @@ void *thr_writer(void *_count) test_array.a = 8; pthread_rwlock_unlock(&lock); nr_writes++; - if (!test_duration_write()) + if (unlikely(!test_duration_write())) break; - if (wdelay) + if (unlikely(wdelay)) usleep(wdelay); } diff --git a/test_urcu.c b/test_urcu.c index d300610..5861281 100644 --- a/test_urcu.c +++ b/test_urcu.c @@ -168,7 +168,7 @@ void *thr_reader(void *_count) assert(local_ptr->a == 8); rcu_read_unlock(); nr_reads++; - if (!test_duration_read()) + if (unlikely(!test_duration_read())) break; } @@ -208,9 +208,9 @@ void *thr_writer(void *_count) old->a = 0; test_array_free(old); nr_writes++; - if (!test_duration_write()) + if (unlikely(!test_duration_write())) break; - if (wdelay) + if (unlikely(wdelay)) usleep(wdelay); }