diff options
author | rpj <rpj> | 1999-03-14 05:29:18 +0000 |
---|---|---|
committer | rpj <rpj> | 1999-03-14 05:29:18 +0000 |
commit | f8af93c39f8deebc46aee1b25be9d5c40035d0d8 (patch) | |
tree | 6874f918fe82259682384ccfd2539cf62e6cd217 /tests/condvar4.c | |
parent | c181e5bb2ccf9d351553eaadf66578df441024a6 (diff) |
Mon Mar 15 00:20:13 1999 Ross Johnson <rpj@ixobrychus.canberra.edu.au>snap-1999-03-15
* condvar.c (pthread_cond_init): fix possible uninitialised use
of cv.
Sun Mar 14 21:01:59 1999 Ross Johnson <rpj@ixobrychus.canberra.edu.au>
* 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 <rpj@ixobrychus.canberra.edu.au>
* 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 <rpj@ixobrychus.canberra.edu.au>
* 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.
Diffstat (limited to 'tests/condvar4.c')
-rw-r--r-- | tests/condvar4.c | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/tests/condvar4.c b/tests/condvar4.c index f93db27..ecb5e2d 100644 --- a/tests/condvar4.c +++ b/tests/condvar4.c @@ -1,5 +1,5 @@ /* - * File: condvar1.c + * File: condvar4.c * * Test Synopsis: * - Test PTHREAD_COND_INITIALIZER. @@ -50,11 +50,13 @@ typedef struct cvthing_t_ cvthing_t; struct cvthing_t_ { pthread_cond_t notbusy; pthread_mutex_t lock; + int shared; }; static cvthing_t cvthing = { - PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER, + PTHREAD_MUTEX_INITIALIZER, + 0 }; enum { @@ -66,10 +68,12 @@ mythread(void * arg) { assert(pthread_mutex_lock(&cvthing.lock) == 0); - assert(pthread_cond_signal(&cvthing.notbusy) == 0); + cvthing.shared++; assert(pthread_mutex_unlock(&cvthing.lock) == 0); + assert(pthread_cond_signal(&cvthing.notbusy) == 0); + return 0; } @@ -85,10 +89,18 @@ main() #endif const DWORD NANOSEC_PER_MILLISEC = 1000000; + cvthing.shared = 0; + assert((t[0] = pthread_self()) != NULL); + assert(cvthing.notbusy == PTHREAD_COND_INITIALIZER); + + assert(cvthing.lock == PTHREAD_MUTEX_INITIALIZER); + assert(pthread_mutex_lock(&cvthing.lock) == 0); + assert(cvthing.lock != PTHREAD_MUTEX_INITIALIZER); + /* get current system time */ _ftime(&currSysTime); @@ -99,6 +111,8 @@ main() assert(pthread_cond_timedwait(&cvthing.notbusy, &cvthing.lock, &abstime) == ETIMEDOUT); + assert(cvthing.notbusy != PTHREAD_COND_INITIALIZER); + assert(pthread_create(&t[1], NULL, mythread, (void *) 1) == 0); _ftime(&currSysTime); @@ -108,11 +122,20 @@ main() abstime.tv_sec += 5; - assert(pthread_cond_timedwait(&cvthing.notbusy, &cvthing.lock, &abstime) == 0); + while (! cvthing.shared > 0) + assert(pthread_cond_timedwait(&cvthing.notbusy, &cvthing.lock, &abstime) == 0); + + assert(cvthing.shared > 0); assert(pthread_mutex_unlock(&cvthing.lock) == 0); + assert(pthread_mutex_destroy(&cvthing.lock) == 0); + + assert(cvthing.lock == NULL); + assert(pthread_cond_destroy(&cvthing.notbusy) == 0); + assert(cvthing.notbusy == NULL); + return 0; } |