aboutsummaryrefslogtreecommitdiff
path: root/utils/stress/patches/010-usleep.patch
blob: 02a2201848e1ce3e4fd2fc62014b6f023e4656f8 (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
47
48
49
50
51
--- a/src/stress.c
+++ b/src/stress.c
@@ -266,9 +266,12 @@ main (int argc, char **argv)
     while ((forks = (do_cpu + do_io + do_vm + do_hdd)))
     {
         long long backoff, timeout = 0;
+        struct timespec b;
 
         /* Calculate the backoff value so we get good fork throughput.  */
         backoff = do_backoff * forks;
+        b.tv_sec = backoff / 1000000;
+        b.tv_nsec = (backoff % 1000000) * 1000;
         dbg (stdout, "using backoff sleep of %llius\n", backoff);
 
         /* If we are supposed to respect a timeout, calculate it.  */
@@ -304,7 +307,7 @@ main (int argc, char **argv)
             case 0:            /* child */
                 worker_init();
                 alarm (timeout);
-                usleep (backoff);
+                nanosleep (&b, NULL);
                 if (do_dryrun)
                     exit (0);
                 exit (hogcpu ());
@@ -326,7 +329,7 @@ main (int argc, char **argv)
             case 0:            /* child */
                 worker_init();
                 alarm (timeout);
-                usleep (backoff);
+                nanosleep (&b, NULL);
                 if (do_dryrun)
                     exit (0);
                 exit (hogio ());
@@ -347,7 +350,7 @@ main (int argc, char **argv)
             case 0:            /* child */
                 worker_init();
                 alarm (timeout);
-                usleep (backoff);
+                nanosleep (&b, NULL);
                 if (do_dryrun)
                     exit (0);
                 exit (hogvm (do_vm_bytes, do_vm_stride, do_vm_hang, do_vm_keep));
@@ -368,7 +371,7 @@ main (int argc, char **argv)
             case 0:            /* child */
                 worker_init();
                 alarm (timeout);
-                usleep (backoff);
+                nanosleep (&b, NULL);
                 if (do_dryrun)
                     exit (0);
                 exit (hoghdd (do_hdd_bytes));