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