MIT 6.S081 Lab syscall
Compulsory exercises
Preparation
-
reading
-
To start the lab, switch to the syscall branch:
1 | git fetch |
System call tracing (moderate)
-
了解trace的过程
- trace.c调用系统调用trace()
- 系统调用trace()调用sys_trace()设置进程的mask
-
理解mask的含义
- mask作为作为系统调用序号的掩码,如mask = (1 << SYS_read) | (1 << SYS_fork)代表同时trace read 和 fork系统调用
- 当mask = 2147483647时代表trace序号1 - 31的系统调用
- question: mask的类型? uint64 or uint32? 理论上都是可行的
-
添加编译依赖
-
添加trace系统调用
code
-
add sys_trace()
1 | // add in sysproc.c |
1 | // add in proc.h struct proc |
-
Modify fork()
1 | // add in proc.c |
-
Modify the syscall()
1 | // add and modify in syscall.c |
Sysinfo (moderate)
-
了解sysinfo的过程
- sysinfotest调用sysinfo()
- 系统调用sysinfo()调用sys_sysinfo获取struct sysinfo
-
添加编译依赖
-
添加sysinfo系统调用
code
-
add sysinfo()
1 | // add in sysproc.c |
- add freemem()
1 | // add in kalloc.c |
- add procnumber()
1 | // add in proc.c |
Optional challenge exercises
-
Print the system call arguments for traced system calls (easy).
-
Compute the load average and export it through sysinfo(moderate).
MIT 6.S081 Lab syscall