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-01-18 14:25:09 +0800
commit33ca12a4653752d179e6296c7ca2f91a626d30f3 (patch)
tree819af498462a8a0f725c408c08aa0dae53f6f07b /user/sleep.c
parente6ef31e4b30af1f30a4d1385971df602a8446cac (diff)
downloadxv6-labs-33ca12a4653752d179e6296c7ca2f91a626d30f3.tar.gz
xv6-labs-33ca12a4653752d179e6296c7ca2f91a626d30f3.tar.bz2
xv6-labs-33ca12a4653752d179e6296c7ca2f91a626d30f3.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);
+}