Read the textbook. In Chapter 1: Skim through: 1.4 (to understand "lwp" in proc_t member names) 1.7 (keep in mind that we look at x86, not SPARC) 1.8 (what VFS and vnode are) Chapter 2: As you read, keep looking at proc_t definition and try commands from 2.13 in "mdb -k" (must be root) Read carefully: 2.1 - 2.5 (especially 2.4 and Fig. 2.3) The figures are the best part of the book, spend time understanding them and following the links/pointers in code or actual memory (with mdb -k) 2.8 (again, keep in mind we are on x86) 2.10-2.10.1 (the /proc filesystem, keep looking at the code in http://src.illumos.org/source/xref/illumos-gate/usr/src/uts/common/fs/proc/prvnops.c and Fig. 2.10) 2.12 (explains PID hash chains, sheds light on some of the pointer links in proc_t) ========= Navigate code ===== 0. Start searches at http://src.illumos.org/source/ (linked off http://illumos.org/) Kernel code "lives" under project "illumos-gate", under the path /illumos-gate/usr/src/uts/ (note UTS) The best way to read the code is to follow a data structure traversal, e.g., by a system call (http://src.illumos.org/source/xref/illumos-gate/usr/src/uts/common/syscall/SYSCALL.README) -- and compare with textbook's Figures. 1. Look at proc_t definition. We will keep coming back to it. In class, we looked at pieces of http://src.illumos.org/source/xref/illumos-gate/usr/src/uts/common/fs/proc/prvnops.c , e.g. tables of proc's pseudo-file specific read and readdir variants (pr_read_function, pr_readdir_function) for each reported file and directory name under /proc ) 2. Look at how the "process context" is found in a simple system call such as /illumos-gate/usr/src/uts/common/syscall/getpid.c what are curthread, curproc ? What does threadp() do? (Note: for functions that include assembly, the kernel contains a "__lint" version of the code that does not actually get built but keeps the compiler in checking ("lint") mode happy. For more info see manpage of "lint"). (Many macros in /illumos-gate/usr/src/uts/common/sys/thread.h are nice and readable; the key point is threadp(), which is CPU-dependent.) (Note: __xpv code snippets are to support Xen. Xen is a "paravirtualization" system, which means that the guest OS kernel must be modified in places to run on top of Xen. __xpv variants are there to build such a Solaris kernel). 3. Assembly subroutines (threadp() and anything that reads and writes specific registers, which, by convention, store "context", such as cr3 [points to page tables of a process on x86] or %gs [segment selector used to point to thread-local storage of a process, makes "process context" proc_t findable] /illumos-gate/usr/src/uts/intel/ia32/ml/i86_subr.s shows many examples of assembly subroutines for x86. Again, remember to ignore __lint variants, they are there to pass various compiler checks of the matching function type signatures, data flows, etc. Note the functions that read and write special registers: cr0, cr2, cr3. Note strlen. There are references to "Ferrari" in this file. I saw Sun engineers with Ferrari-branded laptops running Solaris. For those of you who are familiar with the IP protocol packet format (google images for "ip header"), look at ip_ocsum() (line 2420)