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

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.lryc.cn/news/232246.html

相关文章:

  • 修改 jar 包中的源码方式
  • Linux命令--重启系统的方法
  • 操作系统 day10(调度的概念、层次、七状态模型)
  • MIB 6.1810操作系统实验:准备工作(Tools Used in 6.1810)
  • 快速弄懂C++中的深拷贝和浅拷贝
  • AWD比赛中的一些防护思路技巧
  • 【C++面向对象】14. 命名空间
  • asp.net实验管理系统VS开发sqlserver数据库web结构c#编程web网页设计
  • 基于SSM+Vue的健身房管理系统
  • 《C++避坑神器·二十三》C++异常处理exception
  • 安卓播放解码后的byte字节视频
  • ceph 14.2.10 aarch64 非集群内 客户端 挂载块设备
  • 21、Flink 的table API与DataStream API 集成(2)- 批处理模式和inser-only流处理
  • 051-第三代软件开发-日志容量时间限制
  • 9步打造个人ip
  • 【深度学习】吴恩达课程笔记(四)——优化算法
  • MyBatis-plus 代码生成器配置
  • 框架设计的核心要素
  • LeetCode - 26. 删除有序数组中的重复项 (C语言,快慢指针,配图)
  • C#不安全代码
  • 《C++避坑神器·二十二》VS能正常运行程序,但运行exe程序无响应解决办法
  • lua调用C/C++的函数,十分钟快速掌握
  • 自定义GPT已经出现,并将影响人工智能的一切,做好被挑战的准备了吗?
  • vue中一个页面引入多个相同组件重复请求的问题?
  • Uniapp连接iBeacon设备——实现无线定位与互动体验(实现篇)
  • 【ceph】ceph集群删除pool报错: “EPERM: pool deletion is disabled“
  • 【微信小程序】使用npm包
  • 【开发记录篇】第二篇:SQL创建分区表
  • vue 使用 this.$router.push 传参数,接参数的 query或params 两种方法示例
  • rk3588 usb网络共享连接