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

相关推荐
Eric.Lee202120 小时前
ubuntu 安装 Miniconda
linux·运维·python·ubuntu·miniconda
会飞的土拨鼠呀21 小时前
通过Linux进程id找到程序路径
linux·服务器·网络
杭州泽沃电子科技有限公司21 小时前
在线监测:为医药精细化工奠定安全、合规与质量基石
运维·人工智能·物联网·安全·智能监测
行初心21 小时前
uos基础 cupsd.conf 查看打印服务的配置文件
运维
1***y17821 小时前
Git在发布流程中的自动化标签
运维·git·自动化
8***84821 天前
如何在Linux中找到MySQL的安装目录
linux·运维·mysql
9***J6281 天前
Linux下PostgreSQL-12.0安装部署详细步骤
linux·运维·postgresql
W***83201 天前
如何在 Ubuntu 22.04 上安装 MySQL
linux·mysql·ubuntu
gggg远1 天前
docker详解
运维·docker·容器
wanhengidc1 天前
云手机中的数据通常存储在哪里?
运维·服务器·安全·web安全·智能手机