summaryrefslogtreecommitdiff
path: root/user/sleep.c
diff options
context:
space:
mode:
authorMole Shang <[email protected]>2024-01-17 11:33:39 +0800
committerMole Shang <[email protected]>2024-02-05 18:03:17 +0800
commit0d6a64fa06ce6aae729fa05a539eadd88fa59007 (patch)
treeae42de2d64325fc09285fd843851f017b1ef6a6b /user/sleep.c
parentb9af3ad894701e8805dd9f63e646487a7f09f9f3 (diff)
downloadxv6-labs-0d6a64fa06ce6aae729fa05a539eadd88fa59007.tar.gz
xv6-labs-0d6a64fa06ce6aae729fa05a539eadd88fa59007.tar.bz2
xv6-labs-0d6a64fa06ce6aae729fa05a539eadd88fa59007.zip
lab util: finish
Diffstat (limited to 'user/sleep.c')
-rw-r--r--user/sleep.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/user/sleep.c b/user/sleep.c
new file mode 100644
index 0000000..961f558
--- /dev/null
+++ b/user/sleep.c
@@ -0,0 +1,22 @@
+#include "kernel/types.h"
+#include "user/user.h"
+
+int
+main(int argc, char* argv[])
+{
+ uint sec = 0;
+
+ if (argc <= 1) {
+ fprintf(2, "usage: sleep [time (ticks)]\n");
+ exit(1);
+ }
+ sec = atoi(argv[1]);
+
+ sleep(sec);
+
+ if (argc <= 2) {
+ exit(0);
+ }
+
+ exit(0);
+}