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 a system call to xv6. DetailsYour new syscall should look like this: int getppid(void) Your system call returns the process ID of the parent of the calling process. New processes (except the first one) are created by other processes calling
fork(). After a successful call to Note that the first process is constructed by the kernel directly and does not have a parent. In this case, your system call should return -1. The CodeThe source code for xv6 (and associated README) can be found in ~cs537-2/ta/xv6/ . Everything you need to build and run and even debug the kernel is in there. After you have un-tarred the Using gdb (the debugger) may be helpful in understanding code, doing code traces, and is helpful for later projects too. Look at the Makefile to see how to start up the debugger. Get familiar with this fine tool! You will not write many lines of code for this project. Instead, a lot of your time will be spent learning where different routines are located in the existing source code. You may also find the following book about xv6 useful, written by the same team that ported xv6 to x86: book . However, note that the kernel version we use is a little different than the book. Particularly useful for this project: Chapters 0 and 3. 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. TestingFirst, let's make sure you have a working test program. The idea here is simple: we write a testppid.c program for the Linux we are using, and then port it to xv6. Your program should first save its own pid in an variable, and then forks
into two processes: the parent simply waits for the child to exit, while
the child calls Once your If your modified To run the test cases, change directory into the root of your xv6 directory. The tests run with ~cs537-2/ta/tests/1b/runtests . If you failed for a specific test, you can find it in ~cs537-2/ta/tests/1b/ctests/ . Open it and find out what aspect it is testing for, how is your xv6 reacting, and why it does not execute as expected. |