summaryrefslogtreecommitdiff
path: root/tests/condvar1_2.c
diff options
context:
space:
mode:
authorrpj <rpj>2002-02-23 02:01:11 +0000
committerrpj <rpj>2002-02-23 02:01:11 +0000
commitd2b870cd9b6d91261a304e156819571acc309b55 (patch)
tree4b56dbc20070a24a90c123daadc35ab628f21e8c /tests/condvar1_2.c
parent09cf57ffcf96b3f0cf7d5ec959c455ba54245a65 (diff)
* 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.
Diffstat (limited to 'tests/condvar1_2.c')
-rw-r--r--tests/condvar1_2.c42
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;
}