From f8af93c39f8deebc46aee1b25be9d5c40035d0d8 Mon Sep 17 00:00:00 2001 From: rpj Date: Sun, 14 Mar 1999 05:29:18 +0000 Subject: Mon Mar 15 00:20:13 1999 Ross Johnson * condvar.c (pthread_cond_init): fix possible uninitialised use of cv. Sun Mar 14 21:01:59 1999 Ross Johnson * condvar.c (pthread_cond_destroy): don't do full cleanup if static initialised cv has never been used. (cond_timedwait): check result of auto-initialisation. tests/ChangeLog Mon Mar 15 00:17:55 1999 Ross Johnson * mutex1.c: only test mutex init and destroy; add assertions. * count1.c: raise number of spawned threads to 60 (appears to be the limit under Win98). Sun Mar 14 21:31:02 1999 Ross Johnson * test.h (assert): add assertion trace option. Use: "#define ASSERT_TRACE 1" to turn it on, "#define ASSERT_TRACE 0" to turn it off (default). * condvar3.c (main): add more assertions. * condvar4.c (main): add more assertions. * condvar1.c (main): add more assertions. --- tests/condvar3.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'tests/condvar3.c') diff --git a/tests/condvar3.c b/tests/condvar3.c index 27223ab..c2b08e6 100644 --- a/tests/condvar3.c +++ b/tests/condvar3.c @@ -48,8 +48,9 @@ #include "test.h" #include -pthread_cond_t cv; -pthread_mutex_t mutex; +static pthread_cond_t cv; +static pthread_mutex_t mutex; +static int shared = 0; enum { NUMTHREADS = 2 /* Including the primary thread. */ @@ -62,10 +63,12 @@ mythread(void * arg) assert(pthread_mutex_lock(&mutex) == 0); - assert(pthread_cond_signal(&cv) == 0); + shared++; assert(pthread_mutex_unlock(&mutex) == 0); + assert(pthread_cond_signal(&cv) == 0); + return 0; } @@ -99,7 +102,10 @@ main() abstime.tv_sec += 5; - assert(pthread_cond_timedwait(&cv, &mutex, &abstime) == 0); + while (! shared > 0) + assert(pthread_cond_timedwait(&cv, &mutex, &abstime) == 0); + + assert(shared > 0); assert(pthread_mutex_unlock(&mutex) == 0); -- cgit v1.2.3