文章
Mit s6.081 lab
2026暑期自学6.081个人记录
lab1 : Xv6 and Unix utilities
环境配置
//step1
$ git clone git://g.csail.mit.edu/xv6-labs-2021
//step2
$ cd xv6-labs-2021
$ git checkout util
lab 1
sleep
// 新建user/sleep.c
#include "types.h"
#include "user.h"
int main(int argc, char *argv[])
{
// 检查参数是否正确
if(argc != 2){
fprintf(2, "usage: sleep n\n");
exit(1);
}
// 转换参数为整数
int n = atoi(argv[1]);
// 等待n秒
sleep(n);
exit(0);
}
然后打开根目录下的 Makefile 文件,找到 UPROGS 块,在最后一行新增 $U/_sleep(后续不再说明)
运行./grade-lab-util sleep测试

讨论
0