From: Mathieu Desnoyers Date: Wed, 10 Jun 2009 16:06:42 +0000 (-0400) Subject: Make sure the rwlock and per thread lock could detect races X-Git-Tag: v0.1~174 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=2b4e41252ca7ad279d2aa91f2a011b36aa56b224;p=urcu.git Make sure the rwlock and per thread lock could detect races Signed-off-by: Mathieu Desnoyers --- diff --git a/test_perthreadlock.c b/test_perthreadlock.c index 078e659..7b6a65c 100644 --- a/test_perthreadlock.c +++ b/test_perthreadlock.c @@ -69,7 +69,7 @@ static volatile int test_go, test_stop; static int wdelay; -static struct test_array test_array = { 8 }; +static volatile struct test_array test_array = { 8 }; static unsigned long duration; @@ -162,6 +162,7 @@ void *thr_writer(void *data) for (tidx = 0; tidx < nr_readers; tidx++) { pthread_mutex_lock(&per_thread_lock[tidx].lock); } + test_array.a = 0; test_array.a = 8; for (tidx = nr_readers - 1; tidx >= 0; tidx--) { pthread_mutex_unlock(&per_thread_lock[tidx].lock); diff --git a/test_rwlock.c b/test_rwlock.c index 76156cb..ef3ce2c 100644 --- a/test_rwlock.c +++ b/test_rwlock.c @@ -65,7 +65,7 @@ static volatile int test_go, test_stop; static int wdelay; -static struct test_array test_array = { 8 }; +static volatile struct test_array test_array = { 8 }; static unsigned long duration; @@ -152,6 +152,7 @@ void *thr_writer(void *_count) for (;;) { pthread_rwlock_wrlock(&lock); + test_array.a = 0; test_array.a = 8; pthread_rwlock_unlock(&lock); nr_writes++;