MIT 6.S081 Lab: system calls

Result

在这里插入图片描述

1、System call tracing

In this assignment you will add a system call tracing feature that may help you when debugging later labs. You’ll create a new trace system call that will control tracing. It should take one argument, an integer “mask”, whose bits specify which system calls to trace. For example, to trace the fork system call, a program calls trace(1 << SYS_fork), where SYS_fork is a syscall number from kernel/syscall.h. You have to modify the xv6 kernel to print out a line when each system call is about to return, if the system call’s number is set in the mask. The line should contain the process id, the name of the system call and the return value; you don’t need to print the system call arguments. The trace system call should enable tracing for the process that calls it and any children that it subsequently forks, but should not affect other processes.

  • user/user.h
    在这里插入图片描述

  • user/usys.pl
    在这里插入图片描述

  • kernel/syscall.h
    在这里插入图片描述

  • kernel/sysproc.c
    在这里插入图片描述

  • kernel/proc.h
    在这里插入图片描述

  • kernel/proc.c
    在这里插入图片描述

  • kernel/syscall.c在这里插入图片描述

  • kernel/syscall.c
    在这里插入图片描述

2、Sysinfo

In this assignment you will add a system call, sysinfo, that collects information about the running system. The system call takes one argument: a pointer to a struct sysinfo (see kernel/sysinfo.h). The kernel should fill out the fields of this struct: the freemem field should be set to the number of bytes of free memory, and the nproc field should be set to the number of processes whose state is not UNUSED. We provide a test program sysinfotest; you pass this assignment if it prints “sysinfotest: OK”.

  • user/user.h
    在这里插入图片描述

  • kernel/syscall.h
    在这里插入图片描述

  • user/usys.pl
    在这里插入图片描述

  • kernel/defs.h
    在这里插入图片描述

  • To collect the amount of free memory, add a function to kernel/kalloc.c
    在这里插入图片描述

  • To collect the number of processes, add a function to kernel/proc.c

在这里插入图片描述

  • kernel/sysproc.c, sysinfo needs to copy a struct sysinfo back to user space

在这里插入图片描述

  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 9
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值