Xv6
Jump to navigation
Jump to search
Originally Minix, just like Xv6, was designed for educational purposes. As years went by, Minix became more complex and more like a real OS, so that at version 3 being educational was not a goal anymore. So much that Tanenbaum officially changed its focus to being fully functional. As a result, its codebase does not help beginners any more. Thankfully we still have Xv6, which remained a simple educational OS.
History
Xv6 is a re-implementation of the classic Dennis Richie's and Ken Thompson's UNIX V6 for MIT Operating System course. UNIX was originally written in K&R C for the PDP-11. Xv6 is a modernized version of that, written in ANSI C for the Intel x86 and RISC-V processor, keeping the original UNIX philosophy of simplicity.
Advantages
- Very small codebase. Being educational, it focuses on how an OS should work instead of implementing everything. A single programmer can easily overview its entire codebase.
- K.I.S.S. uses clear and simple algorithms only, most sources are no longer than few hundred lines.
- Minimal assembly. Most of the code is written in ANSI C.
- Uses protected mode on x86. It abstracts the x86 architecture away with minimal lines of code, and it does not rely on BIOS.
- Fairly modern. It supports IOAPIC, LAPIC etc. It does not use obsolete devices such as floppies like other tutorials do.
- Fairly sophisticated. It uses paging for virtual address spaces, and it is a multitasking OS with symmetric multiprocessing (SMP) support.
- Fully functional. Unlike most tutorials and bare-bones, Xv6 really implements everything that has to be implemented in a working kernel.
- Easy to understand. Has a great commentary book, that also points out which parts of the kernel should be refactored for a real-life OS and how.
Disadvantages
- Unlike Minix, Xv6 is a monolithic kernel, which means OS layers are not separated.
- Source is not separated either, furthermore kernel space code is mixed with user space code. Thankfully there's a list of files grouped by which module they belong. Everything not listed there is user space code.
External Links
- Xv6 homepage
- Commentary book on Xv6 in PDF, it is brief (less than 100 pages) and an easy reading
- Source on GitHub
- hhp3 walkthrough on YouTube