当前位置: 首页 > article >正文

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

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


http://www.kler.cn/news/133810.html

相关文章:

  • 九、Linux用户管理
  • Windows安装多个版本的Java
  • vue.js javascript js判断是值否为空
  • 庖丁解牛:NIO核心概念与机制详解 03 _ 缓冲区分配、包装和分片
  • 八股文-TCP的三次握手
  • C++-特殊类和单例模式
  • Leetcode—142.环形链表II【中等】
  • 基于springboot实现智能热度分析和自媒体推送平台系统项目【项目源码】
  • 将AI技术与VR元宇宙相结合的整体解决方案
  • 【Redis】zset常用命令集合间操作内部编码使用场景
  • 智能驾驶汽车虚拟仿真视频数据理解(一)
  • Java学习之路 —— Java高级
  • 2023-11-17 VsCode使用makefile进行多文件编译
  • 前端js常用代码段总结
  • 多功能神器,强劲升级,太极2.x你值得拥有!
  • Java Swing模拟银行自动取款机
  • OpenHarmony源码下载
  • mount /dev/mapper/centos-root on sysroot failed处理
  • python命名空间字典
  • git 相关指令总结(持续更新中......)
  • 力扣labuladong——一刷day38
  • 车载通信架构 —— 传统车内通信网络发展回顾
  • 微积分在神经网络中的本质
  • 基于JavaWeb+SpringBoot+掌上社区疫苗微信小程序系统的设计和实现
  • 腾讯微服务平台TSF学习笔记(一)--如何使用TSF的Sidecar过滤器实现mesh应用的故障注入
  • 二维码智慧门牌管理系统升级解决方案:查询功能大提升,让地址查找变得轻松便捷!
  • 比较两个数组内容是否相同
  • 【机器学习6】概率图模型
  • 滑动窗口练习(一)— 固定窗口最大值问题
  • LinkWeChat V4.9.8 版本发布