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

相关推荐
勤源科技3 分钟前
全链路智能运维中的多模态数据融合与语义对齐技术
运维
大聪明-PLUS9 分钟前
QEMU:如何组织与 I2C 设备的透明交互
linux·嵌入式·arm·smarc
IsWillian13 分钟前
OpenSSL生成自签名通配符证书
运维·服务器
一念&25 分钟前
每日一个网络知识点:网络层NAT
服务器·网络·php
QWQ___qwq28 分钟前
Swift中.gesture的用法
服务器·microsoft·swift
sulikey44 分钟前
【Linux权限机制深入理解】为何没有目录写权限仍能修改文件权限?
linux·运维·笔记·ubuntu·centos
济南java开发,求内推1 小时前
单个服务器部署多个rabbitmq
运维·服务器·rabbitmq
wanhengidc1 小时前
云手机的多元功能应用
运维·服务器·网络·游戏·智能手机
liu****1 小时前
8.list的模拟实现
linux·数据结构·c++·算法·list
biubiubiu07061 小时前
VPS SSH密钥登录配置指南:告别密码,拥抱安全
linux