Skip to content

Commit

Permalink
lab util sleep solution
Browse files Browse the repository at this point in the history
  • Loading branch information
forbidden-game committed Mar 15, 2023
1 parent f654383 commit 0f654b3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ UPROGS=\
$U/_grind\
$U/_wc\
$U/_zombie\
$U/_sleep



Expand Down
24 changes: 24 additions & 0 deletions user/sleep.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// Created by ForbiddenGame on 2023/3/15.
//

#include "kernel/types.h"
#include "user/user.h"

int
main(int argc, char* argv[])
{
if(argc <= 1){
fprintf(2, "usage sleep [time]\n");
exit(1);
}

if(argv[1][0] == '-'){
fprintf(2, "time must be positive\n");
exit(1);
}

int time = atoi(argv[1]);
sleep(time);
exit(0);
}

0 comments on commit 0f654b3

Please sign in to comment.