summaryrefslogtreecommitdiff
path: root/tests/condvar3.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/condvar3.c')
-rw-r--r--tests/condvar3.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/tests/condvar3.c b/tests/condvar3.c
index 27223ab..c2b08e6 100644
--- a/tests/condvar3.c
+++ b/tests/condvar3.c
@@ -48,8 +48,9 @@
#include "test.h"
#include <sys/timeb.h>
-pthread_cond_t cv;
-pthread_mutex_t mutex;
+static pthread_cond_t cv;
+static pthread_mutex_t mutex;
+static int shared = 0;
enum {
NUMTHREADS = 2 /* Including the primary thread. */
@@ -62,10 +63,12 @@ mythread(void * arg)
assert(pthread_mutex_lock(&mutex) == 0);
- assert(pthread_cond_signal(&cv) == 0);
+ shared++;
assert(pthread_mutex_unlock(&mutex) == 0);
+ assert(pthread_cond_signal(&cv) == 0);
+
return 0;
}
@@ -99,7 +102,10 @@ main()
abstime.tv_sec += 5;
- assert(pthread_cond_timedwait(&cv, &mutex, &abstime) == 0);
+ while (! shared > 0)
+ assert(pthread_cond_timedwait(&cv, &mutex, &abstime) == 0);
+
+ assert(shared > 0);
assert(pthread_mutex_unlock(&mutex) == 0);