diff options
Diffstat (limited to 'tests/condvar1_2.c')
-rw-r--r-- | tests/condvar1_2.c | 42 |
1 files changed, 23 insertions, 19 deletions
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; } |