]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
helgrind/tests/tc08_hbl2: Avoid busy-waiting
authorBart Van Assche <bvanassche@acm.org>
Sun, 23 Oct 2011 13:28:20 +0000 (13:28 +0000)
committerBart Van Assche <bvanassche@acm.org>
Sun, 23 Oct 2011 13:28:20 +0000 (13:28 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12216

helgrind/tests/tc08_hbl2.c

index 9c05e38d073c57bac1ed48f677aa75373b9f0e05..8cc682b74e4d1e007b74595cfb956190b7b8da07 100644 (file)
@@ -102,7 +102,8 @@ void* child_fn ( void* arg )
 {
    int q = 0;
    int oldx = 0;
-   int ctr = 0;
+   struct timespec ts = { 0, 1000 * 1000 };
+
    while (1) {
       q = (x >= LIMIT);
       if (x != oldx) {
@@ -111,10 +112,7 @@ void* child_fn ( void* arg )
          fflush(stdout);
       }
       if (q) break;
-      /* Make sure the parent doesn't starve.  Seems to be a problem
-        on very slow machines. */
-      ctr++;
-      if (ctr == 2000000) sleep(1);
+      nanosleep(&ts, 0);
    }
    return NULL;
 }