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

相关推荐
摇滚侠1 分钟前
CentOS 7 Linux 离线安装 Docker:离线安装包、依赖文件、安装步骤
linux·docker·centos
小鸡脚来咯4 分钟前
怎么配置主机名映射?
linux·windows·macos
Zzqqads4 分钟前
vnc连接问题:Timed out waiting for a response from the computer
服务器
咖啡の猫9 分钟前
TypeScript基本类型
linux·ubuntu·typescript
玖疯子12 分钟前
JavaScript性能优化实战的技术文章大纲
服务器
DeeplyMind12 分钟前
第4章:DebugFS 安全性和并发控制
linux·驱动开发·debugfs
CS Beginner21 分钟前
【Linux】快速配置wifi和SSH服务
linux·运维·ssh
我也要当昏君21 分钟前
第一节(代入排除法)
运维
become__better21 分钟前
判断ceph osd 节点磁盘异常
linux·运维·ceph
JavaWizard-M25 分钟前
centos7官方下载链接
linux·centos