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

相关推荐
daad7776 分钟前
bitcoin HD钱包示例 真实使命7
运维·服务器
BestOrNothing_201514 分钟前
Ubuntu 22.04 下调整 VS Code 界面及字体教程
linux·vscode·ubuntu22.04·界面调整
Zero-Talent23 分钟前
TCP/IP协议
运维·服务器·网络
桌面运维家25 分钟前
Windows/Linux云桌面:高校VDisk方案部署指南
linux·运维·windows
Du_chong_huan28 分钟前
1.7 计算机网络和因特网的历史 | 《计算机网络:自顶向下方法》精读版
运维·服务器·网络
ZZZKKKRTSAE37 分钟前
rhel9快速上手Docker
运维·docker·容器
筱顾大牛38 分钟前
Docker安装教程(加汉化!超详细!!!)
运维·docker·容器
没头脑的男大40 分钟前
关于tailscale和ssh那些事儿
运维·服务器·ssh
mzhan0171 小时前
Linux:intel:Cache Allocation tech
linux·cpu
竹之却1 小时前
OpenClaw 接入QQ-Bot + 接入Feishu(飞书)
运维·服务器·飞书·openclaw·qq-bot·opencalw接入qq+飞书