Test yourself
Twenty-five questions in each of twenty areas, all checked by your browser. When an answer is wrong you are told the most likely line of thinking that led to it, then the right way to think about it, with links to the code, the tours and the concept pages. Your progress is kept in this browser only.
1Build, link and bootHow make, the linker script and mkfs produce kernel/kernel and fs.img, and how three harts get from QEMU's boot ROM through _entry, start and main to the first process.2RISC-V privilege and CSRsMachine, supervisor and user mode, the control and status registers xv6 uses, what the hardware does on a trap, mret and sret, and why every CSR belongs to one hart.3Traps and system callsHow a user program asks the kernel for a service, what ecall and the trap path do, how usertrap and kerneltrap sort traps by scause, and how a system call's number, arguments and result travel through the trapframe.4Trampoline and trapframeThe border between user and kernel - one trampoline page mapped at the same address in every page table, one trapframe page per process, and the stackless assembly in uservec and userret that crosses it in both directions.5Interrupts, the PLIC and the timerHow the Sstc timer and the PLIC raise interrupts, which hart takes them and when, how devintr tells them apart, and how claim, complete and stimecmp acknowledge them.6The stacksUser stacks, kernel stacks and the boot-turned-scheduler stack, the four instructions that move sp between them, where interrupts push their frames, and the save areas that are not stacks.7Scheduling and swtchOne scheduler loop per hart, the 14 registers swtch saves, the p->lock handed across every switch, and the intena bookkeeping that keeps interrupts honest.8fork, exec, exit, wait, killHow a process is born as a copy, becomes a new program, dies in two halves as a zombie, is reaped by its parent, and is killed by a flag it checks itself.9Spinlocks and interrupt stateacquire and release at the instruction level, push_off/pop_off, noff and intena, and why interrupts must be off while a spinlock is held.10Sleep/wakeup and sleep-locksHow this tree's sleep_prepare, sleep and wakeup avoid lost wakeups without passing a lock to sleep, why every sleep sits in a loop, and how sleep-locks are built on top of them.11Lock order and deadlockHow two locks taken in opposite orders freeze three harts, the one written rule (wait_lock before any p->lock), and the releases, refusals and reference counts that keep every other path in xv6 in a consistent order.12Memory ordering and atomicsThe one atomic swap and the handful of fences xv6 relies on, what RVWMO lets other harts see, why the started flag needs release and acquire, what volatile does and does not do, and how locks carry data (and saved registers) from hart to hart.13Page tables and address spacesSv39 page tables in this kernel, from PTE bits and walk() to the kernel's direct map, the trampoline mapped twice, satp and the TLB on each hart, and what a user address space really contains.14Physical memory, sbrk and page faultsThe kalloc free list and kmem.lock, junk fills and who zeroes pages, eager sbrk versus lazy sbrklazy, and how vmfault turns a page fault into a page or a kill.15User pointers: copyin, copyout, argumentsHow the kernel reads system-call arguments from the trapframe and copies user memory in and out by walking the process's page table in software, page by page, so that a bad pointer becomes -1 instead of a kernel crash.16The disk driver and the buffer cacheHow bread and brelse share 30 cached blocks between harts with a spinlock, a sleep-lock and a reference count, and how virtio_disk_rw hands a request to the disk through descriptors, rings and a doorbell, then sleeps until the interrupt.17Logging and crash recoverybegin_op, log_write and end_op, group commit, the single header write that commits a transaction, and how the next boot redoes it.18Inodes, directories and path lookupThe inode table, ref versus nlink, iget/ilock/iput, directories as arrays of dirents, namex's one-lock-at-a-time walk, and create, link and unlink.19Files, pipes, the console and the UARTHow one read or write is routed by struct file, how a pipe's two counters and two channels move bytes between processes, and how the console and the UART share one wire between processes, interrupt handlers and printk.20User space: ulib, usys and the shellHow a user program starts, calls the kernel through the usys stubs and the small ulib/printf/malloc library, and how the shell parses a command line and wires pipes and redirections with fork, close, dup and exec.