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

相关推荐
-ONLY-¥3 分钟前
PostgreSQL运维全攻略:从基础操作到远程配置
linux
fengfuyao9853 分钟前
VC++基于服务器的点对点文件传输实例
服务器·开发语言·c++
favour_you___4 分钟前
epoll惊群问题与解决
服务器·网络·tcp/ip·epoll
北方的流星12 分钟前
华三网络设备的路由重定向配置
运维·网络·华三
河南博为智能科技有限公司12 分钟前
蓄电池在线监测系统-守护数据中心安全防线
运维·边缘计算
SkyWalking中文站19 分钟前
使用 TraceQL 查询 SkyWalking 和 Zipkin 链路追踪数据并在 Grafana 中可视化
运维·grafana·监控
独小乐19 分钟前
009.中断实践之实现按键测试|千篇笔记实现嵌入式全栈/裸机篇
linux·c语言·驱动开发·笔记·嵌入式硬件·arm
kobe_OKOK_23 分钟前
S7 adapter Docker run
运维·docker·容器
披着羊皮不是狼24 分钟前
将Ubuntu从C盘移动到D盘
linux·运维·ubuntu
炜宏资料库27 分钟前
产业集团总部大楼智能化系统项目规划方案精讲
运维·服务器·数据库