2023-04-14
Operating Systems #0 — Getting Started
These are my notes on the operating systems course I took in the first semester of my third year.
The course ran on three tracks: lectures following the slides, weekly labs where you wrote answers to a handful of questions, and three projects where you modified xv6 directly. They weren't three separate subjects. You learned a name in lecture, found that name in the xv6 source in lab, and changed it yourself in the project.
What's in this series
The notes follow those three tracks.
| Part | Topic | Source |
|---|---|---|
| #1 | Computer system overview — registers, fetch-execute, interrupts, cache | Lecture |
| #2 | Operating system overview — multiprogramming, dual mode, system calls | Lecture |
| #3 | Processes and threads — PCB, state transitions, fork/exec | Lecture + lab |
| #4 | CPU scheduling — from FCFS to MLFQ | Lecture |
| #5 | Process synchronization — race conditions, semaphores, deadlock | Lecture + lab |
| #6 | Traps and system calls in xv6 — IDT, alltraps, the boot sequence | Lab |
| #7 | Putting an MLFQ scheduler into xv6 | Project 1 |
| #8 | Memory management — allocation strategies, page replacement, CoW | Lab |
| #9 | Building LWPs and a process manager in xv6 | Project 2 |
| #10 | Extending the xv6 file system — multi-indirect, symlinks, buffered I/O | Project 3 |
xv6
Every lab and project runs on xv6, MIT's teaching Unix — a rewrite of Sixth
Edition UNIX for x86. It's under ten thousand lines, so you never spend time
hunting for where the scheduler lives. You open proc.c, there's
scheduler(), and that really is all of it.
You read in the textbook that "a PCB holds the process state, its registers, and
its scheduling information," then open struct proc in proc.h and find those
things sitting there as fields. That correspondence was the best part of the
course.
How these are written
They aren't transcriptions of the slides. They're closer to a record of what confused me and how I eventually talked myself into an answer. A few paragraphs end on "I still don't fully get this." That's what the notes said at the time, and I've left them in.