Project 1b: xv6 IntroWe'll be doing kernel hacking projects in xv6 , a port of a classic version of unix to a modern processor, Intel's x86. It is a clean and beautiful little kernel, and thus a perfect object for our study and usage. This first project is just a warmup, and thus relatively light on work. The goal of the project is simple: to add two system calls to xv6. The system calls are:
Each system call will simply return the value of one of two counters; you will need to add both of these new counters. One of the counters will be incremented before any system call is issued (this counter is returned by getsyscallnumtotal()). The other counter will be incremented after the system call has returned, if and only if the system call did not return a -1 (this counter is returned by getsyscallnumsuccess()). DetailsYour new syscalls should look like this: int getsyscallnumtotal(void) and int getsyscallnumsuccess(void) . getsyscallnumtotal() returns the number of system calls made since the system booted. This count should incremented before a system call is issued, not after. getsyscallnumsuccess() returns the number of system calls (since the system booted) that returned successfully. System calls that have not yet returned should not be included in this count. System calls that are not successful (i.e., that return -1) should not be included. This count should incremented after a system call returns. TipsFind some other system call, like getpid() . Basically, copy it in all the ways you think are needed. Then modify it to do what you need. Most of the time will be spent on understanding the code. There shouldn't be a whole lot of code added. Using gdb (the debugger) may be helpful in understanding code, doing code traces, and is helpful for later projects too. Get familiar with this fine tool! We didn't talk about fork() and exec() system calls in 537 yet. Thus, you may not yet know that on success, exec() does not return to the caller. Therefore, you can ignore exec() in this project and assume we will not run any test cases for exec(). The CodeThe source code for xv6 (and associated README) can be found in ~cs537-1/ta/xv6/ . Everything you need to build and run and even debug the kernel is in there; start by reading the README. You may also find the following book about xv6 useful, written by the same team that ported xv6 to x86: book . Particularly useful for this project: Chapters 0 and 3 (and maybe 4). Note that our version of xv6 is slightly older than the book's, so you may encounter a difference here and there. |