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

打印 上一主题 下一主题

主题 933|帖子 933|积分 2799

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. }
    复制代码
    免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

科技颠覆者

金牌会员
这个人很懒什么都没写!

标签云

快速回复 返回顶部 返回列表