Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Pfaff <tpfaff@gmx.net>2003-04-08 22:29:37 +0400
committerThomas Pfaff <tpfaff@gmx.net>2003-04-08 22:29:37 +0400
commite3501c78cad9d0a94e9004d4cfc40fe3c783549f (patch)
treeec8813aee63d042f021631a14abe767d75774a6d /winsup/testsuite/winsup.api/pthread
parent29d0fe3f748c5a2d26a3fe3e3fe925ca94ff02e2 (diff)
* winsup.api/pthread/condvar9.c: Fix test.
Diffstat (limited to 'winsup/testsuite/winsup.api/pthread')
-rw-r--r--winsup/testsuite/winsup.api/pthread/condvar9.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/winsup/testsuite/winsup.api/pthread/condvar9.c b/winsup/testsuite/winsup.api/pthread/condvar9.c
index 04b8d32fa..294556266 100644
--- a/winsup/testsuite/winsup.api/pthread/condvar9.c
+++ b/winsup/testsuite/winsup.api/pthread/condvar9.c
@@ -18,7 +18,7 @@
* -
*
* Description:
- * - Make NUMTHREADS threads wait on CV, cancel one, broadcast signal them,
+ * - Make NUMTHREADS threads wait on CV, broadcast signal them, cancel them
* and then repeat.
*
* Environment:
@@ -79,6 +79,7 @@ static pthread_mutex_t start_flag = PTHREAD_MUTEX_INITIALIZER;
static struct timespec abstime = { 0, 0 };
static int awoken;
+static int not_canceled;
static void *
mythread(void * arg)
@@ -107,14 +108,18 @@ mythread(void * arg)
while (! (cvthing.shared > 0))
assert(pthread_cond_timedwait(&cvthing.notbusy, &cvthing.lock, &abstime) == 0);
+ assert(cvthing.shared > 0);
+
+ awoken++;
+
+ pthread_testcancel();
+
pthread_cleanup_pop(0);
#ifdef _MSC_VER
#pragma inline_depth()
#endif
- assert(cvthing.shared > 0);
-
- awoken++;
+ not_canceled++;
assert(pthread_mutex_unlock(&cvthing.lock) == 0);
@@ -127,7 +132,6 @@ main()
int failed = 0;
int i;
int first, last;
- int canceledThreads = 0;
pthread_t t[NUMTHREADS + 1];
struct timeb currSysTime;
const DWORD NANOSEC_PER_MILLISEC = 1000000;
@@ -149,6 +153,7 @@ main()
assert((t[0] = pthread_self()) != NULL);
awoken = 0;
+ not_canceled = 0;
for (first = 1, last = NUMTHREADS / 2;
first < NUMTHREADS;
@@ -180,12 +185,11 @@ main()
cvthing.shared++;
- assert(pthread_mutex_unlock(&cvthing.lock) == 0);
-
- assert(pthread_cancel(t[(first + last) / 2]) == 0);
- canceledThreads++;
-
assert(pthread_cond_broadcast(&cvthing.notbusy) == 0);
+ for (i = first; i <= last; i++)
+ assert(pthread_cancel(t[i]) == 0);
+
+ assert(pthread_mutex_unlock(&cvthing.lock) == 0);
/*
* Give threads time to complete.
@@ -225,7 +229,8 @@ main()
* Check any results here.
*/
- assert(awoken == NUMTHREADS - canceledThreads);
+ assert(awoken == NUMTHREADS);
+ assert(not_canceled == 0);
/*
* Success.