MIB 6.1810实验Xv6 and Unix utilities(2)sleep

难度:easy

Implement a user-level sleep program for xv6, along the lines of the UNIX sleep command. Your sleep should pause for a user-specified number of ticks. A tick is a notion of time defined by the xv6 kernel, namely the time between two interrupts from the timer chip. Your solution should be in the file user/sleep.c.

实验目标:使用unix的sleep命令实现一个用户级别的sleep

cd xv6-labs-2023/

cd user

vim user.c

cpp 复制代码
#include "kernel/types.h"
#include "kernel/stat.h"
#include "user/user.h"


int main(int argc, char *argv[])
{
  int n;
  if(argc!=2){
    fprintf(2,"please enter a number!\n");
    exit(1);
  }else{
    n = atoi(argv[1]);
    sleep(n);
    exit(0);
  }
}

写makefile

重新编译:

make qemu

输入sleep可以看到命令

使用./grade-lab-util sleep测试功能是否正常

相关推荐
last demo1 小时前
mysql
运维·数据库·mysql·oracle
灰阳阳1 小时前
Dockerfile实践-构建Nginx镜像
运维·nginx·docker·dockerfile
evo-master2 小时前
网络故障排除方法
linux·服务器·网络
Johnstons2 小时前
网络流量监控工具怎么选
运维·网络·网络故障排除·网络流量分析·网络性能监控
爱学习的小囧3 小时前
VMware Horizon 8 智能卡认证信任库配置攻略:新增 Root CA 导入指南
服务器·esxi·vmware·horizon
信创DevOps先锋4 小时前
中国DevOps工具链选型新趋势:合规、协同与生态融合的平衡之道
运维·gitee·devops
Magic--5 小时前
深入解析管道:最基础的进程间通信(IPC)实现
java·服务器·unix
xlq223225 小时前
35.信号
linux
白鸽梦游指南5 小时前
docker镜像优化
linux·运维·docker
A.A呐6 小时前
【Linux第十九章】网络基础
linux·网络