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

相关推荐
lihui_cbdd17 小时前
AMBER 24 生产环境部署完全指南(5090可用)
linux·计算化学
开发者小天20 小时前
python中For Loop的用法
java·服务器·python
绾樘20 小时前
RHCE--基于Nginx的Web服务器配置
运维·服务器·nginx
生活很暖很治愈20 小时前
Linux基础开发工具
linux·服务器·git·vim
打工的小王21 小时前
docker(三)具体项目的部署
运维·docker·容器
似霰21 小时前
Linux Shell 脚本编程——核心基础语法
linux·shell
步步为营DotNet1 天前
深度剖析.NET中IHostedService:后台服务管理的关键组件
服务器·网络·.net
一叶星殇1 天前
.NET WebAPI:用 Nginx 还是 IIS 更好
运维·nginx·.net
LUCIFER1 天前
[驱动进阶——MIPI摄像头驱动(五)]rk3588+OV13855摄像头驱动加载过程详细解析第四部分——ISP驱动
linux·驱动开发
暮云星影1 天前
四、linux系统 应用开发:UI开发环境配置概述 (一)
linux·ui·arm