操作系统复习 MITS6.1810 lab util 记录

[复制链接]
发表于 2023-7-30 22:47:15 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
lab util

sleep


  • 介绍:主要用来熟悉下环境以及代码结构。


    • See kernel/sysproc.c for the xv6 kernel code that implements the sleep system call (look for sys_sleep), user/user.h for the C definition of sleep callable from a user program, and user/usys.S for the assembler code that jumps from user code into the kernel for sleep.

  • 代码
    1. #include "kernel/types.h"
    2. #include "user/user.h"
    3. int main(int argc, char *argv[])
    4. {
    5.   if (argc <= 1) {
    6.     fprintf(2, "usage: sleep `time`...\n");
    7.   }
    8.   
    9.   int tick_num = atoi(argv[1]);
    10.   sleep(tick_num);
    11.   
    12.   exit(0);
    13. }
    复制代码
    免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!
    继续阅读请点击广告
回复

使用道具 举报

×
登录参与点评抽奖,加入IT实名职场社区
去登录
快速回复 返回顶部 返回列表