Computer Science

xv6: a simple, Unix-like teaching operating system

Russ Cox; Frans Kaashoek; Robert Morris

A complete teaching book tracing operating-system interfaces into a small RISC-V kernel, with memory, traps, scheduling and file-system examples.

Prerequisites

Comfortable C programming, pointers, basic assembly and computer architecture are required. Review virtual memory, stacks and concurrency concepts; compiling and debugging small programs should already feel routine.

Edition
RISC-V revision 5
Publication Year
2025
Difficulty Level
Intermediate
Academic Level
Undergraduate
operating systemsRISC-Vkernel design

01 / Reading Guide

Reading Guide

Operating systems: explain an interleaving before choosing a lock

Compare a free concepts text, a small RISC-V kernel and a broad reference, then solve original event traces and a changed synchronization rule.

Study route and exercise: University Reading List editorial project.

Who this book is for

For undergraduate operating-systems courses that connect concepts directly to implementation. The kernel is deliberately compact enough for students to inspect, but reading it still requires careful reasoning about machine state and concurrent execution. Use the book with the matching RISC-V source revision and the course environment.

Prerequisites

Comfortable C programming, pointers, basic assembly and computer architecture are required. Review virtual memory, stacks and concurrency concepts; compiling and debugging small programs should already feel routine.

What it covers

Operating-system interfaces lead into kernel organization, page tables, traps and system calls, page faults, interrupts, locking, scheduling, sleep and wakeup, and file systems. The text follows code paths and explains design choices. Sections comparing the teaching kernel with real systems help readers recognize which simplifications serve education.

How to use it

Trace a single system call from a user program through the trap handler and back, recording changes of privilege, stack and address space. Draw the state shared between two concurrent paths before considering locks. Reproduce a small behavior in the emulator and explain the result using the code rather than a diagram alone. When changing a mechanism, predict what invariant could fail, then construct a focused test. Keep line references synchronized with the selected source booklet.

Edition and sources

The MIT course route links the source and text; the complete revision 5 PDF is dated September 2, 2025. The book repository grants an MIT-style permissive license, distinct from the historical Unix sources that inspired xv6. Preserve notices when reusing the book.

Open the official resource