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 分钟前
【ELK】-8 logstash的filter模块详解
运维·elk·filter
躺不平的理查德4 分钟前
OpenSSL 的异步 TLS 1.3 加密
linux·运维·服务器
tedcloud1236 分钟前
Awesome DSH Plugin 怎么用?给 DeepSeek Harness 搭建自己的插件生态
大数据·linux·服务器·人工智能·音视频
楷哥爱开发14 分钟前
IPFoxy爬虫代理配置指南:从0搭建Crawl4AI网页爬虫教程
大数据·运维·人工智能·爬虫
钓鱼的小小猫24 分钟前
从零拿捏Linux(一) ---- 命令(视频秒解)
linux·linux命令
A153625536 分钟前
WMS 智能仓情系统推荐:如何实现仓库全局可视与数字化管控
运维·数据库·人工智能
明王明王41 分钟前
Ubuntu 26.04 使用 Windows Spotlight:给 Bing Wallpaper 加上 Spotlight 支持
linux·windows·ubuntu
夜月yeyue43 分钟前
SOME/IP 服务模型
linux·服务器·单片机·安全·车载系统
程序员z71 小时前
深入理解 GMP 模型:Go 协程调度器的设计与调度场景全解析
服务器·网络·golang
一直C1 小时前
【数据结构】哈希表+算法复杂度与经典排序查找(C语言)
java·linux·开发语言·数据结构·算法·ubuntu·散列表