Make sure the rwlock and per thread lock could detect races
authorMathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Wed, 10 Jun 2009 16:06:42 +0000 (12:06 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Wed, 10 Jun 2009 16:06:42 +0000 (12:06 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
test_perthreadlock.c
test_rwlock.c

index 078e6594a19faeddd068a9f49e545992b1553505..7b6a65c8c6fb18a68531e13c19587e44aad6729c 100644 (file)
@@ -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);
index 76156cb01064e335b729be9458f0fdd9a0720c16..ef3ce2c73bb49c14571703c9d9d6eb94e5ba164a 100644 (file)
@@ -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++;
This page took 0.027794 seconds and 4 git commands to generate.