aboutsummaryrefslogtreecommitdiff
path: root/utils/stress/patches/010-usleep.patch
blob: 69467264ce1ed1985a72186e0230ec253404c635 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
--- a/src/stress.c
+++ b/src/stress.c
@@ -262,6 +262,7 @@ main (int argc, char **argv)
 
       /* Calculate the backoff value so we get good fork throughput.  */
       backoff = do_backoff * forks;
+      struct timespec b = {backoff / 1000000, (backoff % 1000000) * 1000};
       dbg (stdout, "using backoff sleep of %llius\n", backoff);
 
       /* If we are supposed to respect a timeout, calculate it.  */
@@ -296,7 +297,7 @@ main (int argc, char **argv)
             {
             case 0:            /* child */
               alarm (timeout);
-              usleep (backoff);
+              nanosleep(&b, NULL);
               if (do_dryrun)
                 exit (0);
               exit (hogcpu ());
@@ -317,7 +318,7 @@ main (int argc, char **argv)
             {
             case 0:            /* child */
               alarm (timeout);
-              usleep (backoff);
+              nanosleep(&b,&b);
               if (do_dryrun)
                 exit (0);
               exit (hogio ());
@@ -337,7 +338,7 @@ main (int argc, char **argv)
             {
             case 0:            /* child */
               alarm (timeout);
-              usleep (backoff);
+              nanosleep(&b, &b);
               if (do_dryrun)
                 exit (0);
               exit (hogvm
@@ -358,7 +359,7 @@ main (int argc, char **argv)
             {
             case 0:            /* child */
               alarm (timeout);
-              usleep (backoff);
+              nanosleep(&b, &b);
               if (do_dryrun)
                 exit (0);
               exit (hoghdd (do_hdd_bytes));