Diff of /tests/condvar7.c [cccaf0] .. [ec8290]  Maximize  Restore

Switch to side-by-side view

--- a/tests/condvar7.c
+++ b/tests/condvar7.c
@@ -159,7 +159,7 @@
 
   cvthing.shared = 0;
 
-  assert((t[0] = pthread_self()) != NULL);
+  assert((t[0] = pthread_self()).p != NULL);
 
   assert(cvthing.notbusy == PTHREAD_COND_INITIALIZER);
 
@@ -174,7 +174,7 @@
 
   abstime.tv_sec += 10;
 
-  assert((t[0] = pthread_self()) != NULL);
+  assert((t[0] = pthread_self()).p != NULL);
 
   awoken = 0;
 
@@ -196,17 +196,17 @@
    */
   Sleep(1000);
 
+  /*
+   * Cancel one of the threads.
+   */
+  assert(pthread_cancel(t[1]) == 0);
+  assert(pthread_join(t[1], NULL) == 0);
+
   assert(pthread_mutex_lock(&cvthing.lock) == 0);
 
   cvthing.shared++;
 
   /*
-   * Cancel one of the threads.
-   */
-  assert(pthread_cancel(t[3]) == 0);
-  Sleep(500);
-
-  /*
    * Signal all remaining waiting threads.
    */
   assert(pthread_cond_broadcast(&cvthing.notbusy) == 0);
@@ -214,9 +214,10 @@
   assert(pthread_mutex_unlock(&cvthing.lock) == 0);
 
   /*
-   * Give threads time to complete.
-   */
-  Sleep(2000);
+   * Wait for all threads to complete.
+   */
+  for (i = 2; i <= NUMTHREADS; i++)
+    assert(pthread_join(t[i], NULL) == 0);
 
   /* 
    * Cleanup the CV.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks