]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Merge r9564 (make pth_cvsimple more reliable) from the DARWIN branch.
authorNicholas Nethercote <njn@valgrind.org>
Thu, 16 Apr 2009 02:04:07 +0000 (02:04 +0000)
committerNicholas Nethercote <njn@valgrind.org>
Thu, 16 Apr 2009 02:04:07 +0000 (02:04 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9565

none/tests/pth_cvsimple.c

index f525e3623b17603240eb7fd806b7ba2def7d942f..b260cfb02ac8accabf15b3438e47c46fc21f0889 100644 (file)
@@ -12,7 +12,7 @@
  * Demonstrates pthread condvars.
  *
  */
-
+#include <unistd.h>
 #include <stdio.h>
 #include <pthread.h>
 
@@ -65,6 +65,7 @@ main(void)
   pthread_t threads[3];
 
   pthread_create(&threads[0], NULL, watch_count, NULL);
+  sleep(1);
   pthread_create(&threads[1], NULL, inc_count,   NULL);
   pthread_create(&threads[2], NULL, inc_count,   NULL);
 
@@ -77,6 +78,7 @@ main(void)
   // pthread_cond_wait() is never called.  Or, we could get a spurious
   // wake-up in watch_count().  Nonetheless, it's very likely that things
   // will work out as expected, since we're starting watch_count() first.
+  // (Also since the sleep() call was added after watch_count()!)
   if (condvar_was_hit == 1)
     printf("condvar was hit!\n");
   else if (condvar_was_hit > 1)