From ec8290acdaea21b16d98f1ef5d4ae8a28ab2109a Mon Sep 17 00:00:00 2001 From: rpj Date: Wed, 3 Nov 2004 01:08:41 +0000 Subject: Mutex, semaphore, thread ID, test suite changes - see ChangeLogs --- tests/condvar7.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'tests/condvar7.c') diff --git a/tests/condvar7.c b/tests/condvar7.c index a5bf4bf..9e0b29c 100644 --- a/tests/condvar7.c +++ b/tests/condvar7.c @@ -159,7 +159,7 @@ main() cvthing.shared = 0; - assert((t[0] = pthread_self()) != NULL); + assert((t[0] = pthread_self()).p != NULL); assert(cvthing.notbusy == PTHREAD_COND_INITIALIZER); @@ -174,7 +174,7 @@ main() abstime.tv_sec += 10; - assert((t[0] = pthread_self()) != NULL); + assert((t[0] = pthread_self()).p != NULL); awoken = 0; @@ -196,15 +196,15 @@ main() */ Sleep(1000); - assert(pthread_mutex_lock(&cvthing.lock) == 0); - - cvthing.shared++; - /* * Cancel one of the threads. */ - assert(pthread_cancel(t[3]) == 0); - Sleep(500); + assert(pthread_cancel(t[1]) == 0); + assert(pthread_join(t[1], NULL) == 0); + + assert(pthread_mutex_lock(&cvthing.lock) == 0); + + cvthing.shared++; /* * Signal all remaining waiting threads. @@ -214,9 +214,10 @@ main() assert(pthread_mutex_unlock(&cvthing.lock) == 0); /* - * Give threads time to complete. + * Wait for all threads to complete. */ - Sleep(2000); + for (i = 2; i <= NUMTHREADS; i++) + assert(pthread_join(t[i], NULL) == 0); /* * Cleanup the CV. -- cgit v1.2.3