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测试功能是否正常

相关推荐
IT摆渡者2 小时前
VM EXSI7.0存储硬盘故障处理
大数据·linux·github
赵民勇3 小时前
systemd-cgtop命令详解
linux·运维
Zhu7583 小时前
在docker环境部署frp
运维·docker·容器
hhwyqwqhhwy3 小时前
Ubuntu22.04 安装vitis
linux
运维行者_3 小时前
企业带宽监控工具实战:网络流量分析与异常排查的5个关键能力
运维·服务器·开发语言·网络·分布式·后端·php
March.s3 小时前
Nginx 服务器反向代理实战指南
服务器·nginx·github
刚入门的大一新生4 小时前
Linux-Linux第一个系统程序-进度条
linux·运维·服务器
wuminyu4 小时前
JDK21解决虚拟线程IO阻塞原理剖析
java·linux·c语言·jvm·c++
梦想的旅途24 小时前
企业微信自动化实战:客户资料自动修改与备注同步
运维·自动化·企业微信
梦想的旅途24 小时前
企业微信自动化实战:客户通讯录备份与关系自动迁移
运维·自动化·企业微信