Add a sleep utility program
authorBarret Rhoden <brho@cs.berkeley.edu>
Thu, 2 Jun 2016 21:10:08 +0000 (17:10 -0400)
committerBarret Rhoden <brho@cs.berkeley.edu>
Thu, 16 Jun 2016 16:20:25 +0000 (12:20 -0400)
The motivation is so that perf doesn't need to special-case sleeping.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
tests/sleep.c [new file with mode: 0644]

diff --git a/tests/sleep.c b/tests/sleep.c
new file mode 100644 (file)
index 0000000..4cea7b9
--- /dev/null
@@ -0,0 +1,18 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <parlib/parlib.h>
+
+int main(int argc, char **argv)
+{
+       int sleep_time;
+
+       if (argc < 2) {
+               printf("Usage: %s SEC\n", argv[0]);
+               exit(-1);
+       }
+       sleep_time = atoi(argv[1]);
+       if (sleep_time < 0)
+               exit(-1);
+       sys_block(sleep_time * 1000000);
+       return 0;
+}