目录

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

本文是转载文章,点击查看原文
如有侵权,请联系 xyy@jishuzhan.net 删除
相关推荐
weixin_457885821 小时前
智能多媒体处理流水线——基于虎跃办公API的自动化解决方案
运维·数据库·人工智能·ai·自动化
Stringzhua5 小时前
Linux多网卡组Bond0Bond1Bond4
运维·服务器·网络
暮云星影6 小时前
十二、buildroot系统 adb登录权限设置
linux·arm开发·adb
HHONGQI1236 小时前
Linux 基础入门操作 前言 VIM的基本操作 2
linux·运维·服务器·vim
王伯爵6 小时前
接入网和核心网之间的承载网详细介绍
服务器·网络·数据库
qq_543248526 小时前
Linux网络配置与测试
linux·运维·网络
钡铼技术物联网关6 小时前
下一代楼宇自控的中枢神经:ARM终端的生态
大数据·linux·人工智能
依旧风轻6 小时前
深入理解 rsync daemon 模式(守护进程)
linux·ios·rsync·daemon·sqi
成都纵横智控科技官方账号7 小时前
EG8200Mini-104边缘计算网关!聚焦IEC104协议的工业数据转换与远程运维平台
运维·边缘计算·数据采集·104协议·智改数转
小峰编程7 小时前
谈Linux之磁盘管理——万字详解
linux·运维·服务器·经验分享·笔记·centos·运维开发