CS3 Operating Systems 2013-14, Practical Exercise. PHASE 1 ------- The Linux kernel ---------------- Having done your background reading, you will have an idea of the general structure of the kernel. If you haven't already started, now is the time to look at the source code and see how it fits together. In the directory /group/teaching/cs3/os/VBox/linux-2.6.21.1/ you will find the kernel source from which your virtual machine kernel was built. The main subdirectories are as follows: Documentation/ What it says. There's a lot there, but some of it is not up to date. However, there is documentation on the scheduler: sched-design.txt and sched-coding.txt are the two worth looking at; sched-domains.txt describes a facility which I hope we won't need to understand. arch/ This is the directory where the architecture-specific parts of the Linux kernel live. There is only one directory relevant to us; all the others are for other types of machine. It is i386/ This is the code for the Intel PC architecture. Each of these directories has a structure like that of the top-level directory. drivers/ This contains the various device drivers included in the kernel code. You should not need to look at code in here. fs/ This contains code relating to filesystems. Again, you shouldn't need it. include/ This is a critical subdirectory. It contains most of the *.h files where the Linux kernel data structures are defined. The main subdirectory is linux/ which contains most of the *.h files, both those used by the kernel and those used by other programs needing access to Linux interfaces and data structures. There are very many files in here, most of which are irrelevant to you. The other subdirectory is asm/ (a symlink to asm-i386/) which contains architecture-specific data structure definitions. init/ This contains the kernel initialization code. You don't need it. ipc/ Deals with System V style IPC -- not relevant. kernel/ This is the core of the Linux kernel, containing the code you should be looking at. Described in more detail later. lib/ contains a few useful routines for the kernel. (Unlike normal user programs, the kernel cannot use standard libraries. Exercise: why not?) mm/ contains the memory management code, which has been separated out from kernel/ because it's big and complex. net/ various code to do with networking. scripts/ stuff used in the kernel build process. The kernel/ directory contains quite a few files, many of which should not concern us. The following are those that I believe may have to be looked at. exit.c Deals with process termination and clean-up. fork.c " * 'fork.c' contains the help-routines for the 'fork' system call * (see also entry.S and others). * Fork is rather simple, once you get the hang of it, but the memory * management can be a bitch. See 'mm/memory.c': 'copy_page_range()' " futex.c Hopefully not needed for the practical, but might be interesting as an example of mutex implementation. resource.c General routines for doing resource management. sched.c The main scheduler routines. signal.c Implements the Unix process signal mechanism. softirq.c Various code to do with tasklets and related concepts (i.e. assorted kernel actions to be performed on behalf of processes). sys.c Implements many of the sytem calls by which the kernel is accessed by user programs. sysctl.c Implements the /proc filesystem, which allows many system parameters to be read from pseudo-files, or updated by writing to pseudo-files.