From d2b870cd9b6d91261a304e156819571acc309b55 Mon Sep 17 00:00:00 2001 From: rpj Date: Sat, 23 Feb 2002 02:01:11 +0000 Subject: * pthread_cond_destroy.c: Expand the time change critical section to solve deadlock problem. * pthread.c: Add all remaining C modules. * pthread.h: Use dllexport/dllimport attributes on functions to avoid using pthread.def. * sched.h: Likewise. * semaphore.h: Likewise. * GNUmakefile: Add new targets for single translation unit build to maximise inlining potential; generate pthread.def automatically. * Makefile: Likewise, but no longer uses pthread.def. --- tests/condvar1_2.c | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) (limited to 'tests/condvar1_2.c') diff --git a/tests/condvar1_2.c b/tests/condvar1_2.c index 66237ba..4cb7d9d 100644 --- a/tests/condvar1_2.c +++ b/tests/condvar1_2.c @@ -81,7 +81,8 @@ #include "test.h" enum { - NUM_CV = 100 + NUM_CV = 100, + NUM_LOOPS = 100 }; static pthread_cond_t cv[NUM_CV]; @@ -89,34 +90,37 @@ static pthread_cond_t cv[NUM_CV]; int main() { - int i, j; + int i, j, k; int result = -1; pthread_t t; - for (i = 0; i < NUM_CV; i++) + for (k = 0; k < NUM_LOOPS; k++) { - assert(pthread_cond_init(&cv[i], NULL) == 0); - } + for (i = 0; i < NUM_CV; i++) + { + assert(pthread_cond_init(&cv[i], NULL) == 0); + } - j = NUM_CV; - (void) srand((unsigned)time(NULL)); + j = NUM_CV; + (void) srand((unsigned)time(NULL)); - /* Traverse the list asynchronously. */ - assert(pthread_create(&t, NULL, pthread_timechange_handler_np, NULL) == 0); + /* Traverse the list asynchronously. */ + assert(pthread_create(&t, NULL, pthread_timechange_handler_np, NULL) == 0); - do - { - i = (NUM_CV - 1) * rand() / RAND_MAX; - if (cv[i] != NULL) + do { - j--; - assert(pthread_cond_destroy(&cv[i]) == 0); + i = (NUM_CV - 1) * rand() / RAND_MAX; + if (cv[i] != NULL) + { + j--; + assert(pthread_cond_destroy(&cv[i]) == 0); + } } - } - while (j > 0); + while (j > 0); - assert(pthread_join(t, (void **) &result) == 0); - assert (result == 0); + assert(pthread_join(t, (void **) &result) == 0); + assert (result == 0); + } return 0; } -- cgit v1.2.3