A first dip into OS kernel development with xv6 and the 6.1810 labs
One of my favorite courses during my computer science bachelor was the operating systems course. I like learning theory so I soaked up all the concepts taught during the course, but I can’t recall that we had any sort of practical assignments which is such a shame. Then during my master degree there was no operating system course available to take which already made me sad back then and looking back now I even find it more regrettable.
The xv6 kernel is a very small operating system kernel developed for teaching a practical operating system development course at MIT. It is open source and comes with an excellent book that explains concepts, code structure and many core routines in great detail. I have been aware of these resources for a while and with more time on my hands recently, I finally decided to take a deeper look and was so grateful to find the lab assignments for MIT’s 6.828 “Operating System Engineering” course to be fully available online including correctness and regression tests that can be executed locally. The 2023 course website includes setup instructions for the labs and helpful tips, the lab assignments are branches of a publicly accessible git repository that is a fork of the xv6-riscv repository available on github.
The xv6 kernel sources come with a build system that allows booting the kernel in QEMU and includes a debugging target for debugging with GDB. The 10 labs follow the progression of chapters in the book closely and generally add or improve functionality. This ranges from adding simple system calls to reducing lock contention in the file system implementation and driver code for a network interface card. I found the progression of the labs and the exercises themselves to be designed very well and came away with a feeling of deeply learning about implementation challenges of core concepts/functionality. I finished the lab assignments over the course of about 3 months of at least 1-2 days of working on them per week. Each lab consists of 1-3 assignments that generally build up in difficulty and some of the labs were significantly harder or required more work than others.
There is really not enough words of praise I have for the xv6 kernel, the book and the labs, I wholeheartedly recommend anyone who would like to have a hands-on introduction to OS dev to just do the 6.828 labs while reading along in the book. I am happy to have taken the plunge and finding so much joy in the practical approach to learning. It also made realize again how magical I find the field of operating systems, the design considerations, the implementation challenges/hacks and the historical evolution. Being a hoarder, I naturally have already amassed a wealth of OS dev resources to look into, so now is the time to pick something practical to continue the journey :)