-
参考材料
https://pdos.csail.mit.edu/6.828/2020/labs/util.html -
Look at some of the other programs in user/ (e.g., user/echo.c, user/grep.c, and user/rm.c) to see how you can obtain the command-line arguments passed to a program.
grep.c echo.c rm.c int main(){} 括号里的参数是int argc, char* argv[]。argc表示参数个数,argv表示内容。 -
If the user forgets to pass an argument, sleep should print an error message.
要写一个提示错误的语句。printf(“exec error\n”);
exit(1)括号里是1表示出现异常。 -
The command-line argument is passed as a string; you can convert it to an integer using atoi (see user/ulib.c).
如果传入的数字是10,存储到argv[1]里,调用atoi()把字符类型转换成整型。 -
Use the system call sleep.
See kernel/sysproc.c for the xv6 kernel code that implements the sleep system call (look for sys_sleep), user/user.h for the C definition of sleep callable from a u
MIT6s081 lab1 sleep的实现
最新推荐文章于 2024-05-13 00:25:03 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)