Welcome to CS 108. Goal: To explore and use new features of operating systems that appeared during the last decade. To epxlore OS mechanisms that everyone uses every day, but few people know in detail, such as dynamic linking, executable and linkable format, and OS debugging support. To write working, non-trivial kernel code. Software: OpenSolaris and some Linux. Schedule: We meet in 213 Tue, Thu 2-4pm, our X-hour is Wed 4pm. Please feel free to e-mail me (sergey@cs) to schedule appointments. Grading: My plan is to have 2 midterms constituting 30% of the grade each and a course project for 40%. These fractions may change; an impressive (and working) project may count for more. Course project: Implement, improve, or take advantage of a new interesting OS feature. Please start thinking about your project right away. ----------------------------------------------------------------------- We started looking at syscall implementations, and concentrated primarily on x86 architecture as seen by kernel developers -- see, e.g., explanations to Figure 2-1 in the x86 manual (in the course directory). ----------------------------------------------------------------------- Points from Jan 05 lecture. 1. System calls as the centerpiece of a UNIX kernel. All privileged operations in UNIX are performed on behalf of user processes by "system call" code located in the kernel. The data that this code operates on is also located in the kernel and can only be directly accessed when the CPU is in "kernel mode". This ensures that user processes get to use this code only as a "package deal", with the up-front permission and sanity checks being a part of the package. This mechanism is the basis of the OS stability and security. 2. Some Linux/x86 details: User-level code accesses syscall code through the so-called "call gate" mechanism: it sets the number of the desired call in a register (EAX on Linux/x86), sets arguments or pointers to arguments in other registers (EBX, ECX, EDX, ... on Linux) and executes the "int 0x80" instruction. Note that the system call function is accessed only by it number, not by its address, which user-level code cannot "jump" or "call" to (if it tries, a segfault will occur). The "int 0x80" instruction simultaneously puts the CPU into the kernel mode and transfers control to the address stored in the 0x80-th slot of the x86 CPU's Interrupt Descriptor Table (which is pointed to by the CPU's special IDTR register). That address is *the single entry point* for all system calls. Look at the nice Fig. 1 in this IBM developer article on syscalls: http://www.ibm.com/developerworks/linux/library/l-system-calls/ Look at ENTRY(system_call) in: http://lxr.linux.no/linux+v2.6.24/arch/x86/kernel/entry_32.S Observe the sys_call_table: http://lxr.linux.no/linux+v2.6.24/arch/x86/kernel/syscall_table_32.S Details on Linux system calls: http://www.ibm.com/developerworks/linux/library/l-system-calls/ 3. Userland--Kernel separation on x86. Many textbooks and manuals talk about "user mode" and "kernel mode", (sometimes also called "supervisor mode") as special states of the CPU. X86 systems use Intel's abstraction of 4 "protection rings" to run user-mode code in "ring 3" and "kernel-mode" in "ring 0".