</>PatchNote
Back to posts

2023-04-14

Operating Systems #0 — Getting Started

Operating SystemOS 2023xv6

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.

PartTopicSource
#1Computer system overview — registers, fetch-execute, interrupts, cacheLecture
#2Operating system overview — multiprogramming, dual mode, system callsLecture
#3Processes and threads — PCB, state transitions, fork/execLecture + lab
#4CPU scheduling — from FCFS to MLFQLecture
#5Process synchronization — race conditions, semaphores, deadlockLecture + lab
#6Traps and system calls in xv6 — IDT, alltraps, the boot sequenceLab
#7Putting an MLFQ scheduler into xv6Project 1
#8Memory management — allocation strategies, page replacement, CoWLab
#9Building LWPs and a process manager in xv6Project 2
#10Extending the xv6 file system — multi-indirect, symlinks, buffered I/OProject 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.