From 2b4e41252ca7ad279d2aa91f2a011b36aa56b224 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Wed, 10 Jun 2009 12:06:42 -0400 Subject: [PATCH 1/1] Make sure the rwlock and per thread lock could detect races Signed-off-by: Mathieu Desnoyers --- test_perthreadlock.c | 3 ++- test_rwlock.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) 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++; -- 2.34.1