Settings

Theme

Xv6, a simple Unix-like teaching operating system

pdos.csail.mit.edu

118 points by falava 5 years ago · 22 comments

Reader

lordleft 5 years ago

This is super interesting -- for folks who are worked on or with this, what makes Xv6 well-suited for teaching OS concepts? What aspects of the OS are less robust / filled out than a standard Linux or BSD distro? I'm curious about the pedagogical considerations behind this OS.

  • moyix 5 years ago

    I've taught OS three times using xv6 and like it a lot.

    It's very small, which is great. You can print out the entire source code (and there's a makefile target that will produce a printable PDF) and read through it and actually understand the whole system.

    At the same time, it has most of the features of an OS that you might want to cover in an intro course:

    1. A basic round robin scheduler that you can replace with something more interesting like priorities.

    2. A simple FS that still has some advanced features like transactions / crash recovery.

    3. Support for SMP, so you can teach issues like locking / deadlocks.

    4. UNIX-like system call API, that's again easy to extend to show how a new system call might be implemented.

    Off the top of my head, some things it lacks compared to something like Linux:

    1. Driver support. Basically only the vga and old-school IDE disks are supported. I've assigned a mouse driver as a final project before and it went pretty well: https://panda.moyix.net/~moyix/cs3224/fall16/bonus_hw/bonus_...

    2. Related to (1), this means you aren't going to get anything related to networking.

    3. No dynamic linking; every program is static.

    4. Anything graphical (although I've seen people do this as a final project)

  • timsally 5 years ago

    Years ago I took 6.828 at MIT which is an operating systems engineering course for which Xv6 was designed. The part I found most useful as a student was the fact that the entire operating system printed out into a nice slim volume. Many significant subroutines fit entirely on one page. To sum up the pedagogical value: Xv6 is an operating system made as simple as possible, but not simpler.

    After this course I able to translate the skills to real world results in include a small contribution to the Linux kernel, as well as a significant non-public Linux kernel module. I can recommend studying the Xv6 source code and accompanying book to anyone, without reservation. It was a great privilege to have been able to take that class.

  • _russross 5 years ago

    I teach using xv6 and would add a couple more items to what others have already pointed out. They mainly come down to simplifications that remove distractions from the core ideas:

    * The system assumes a fixed amount of RAM and a fixed memory layout, so there is no discovery process and no adaptive code to go with it

    * The process table is just a small array--no dynamic allocation necessary, and the system can just do a linear search to find an unused entry

    * The userspace is simplified. There is a single stack (no threads) of fixed size, mapped memory starts at address 0, and memory is layed out so that only a single number is required to track the size of the entire address space: the size is the top of mapped memory.

    Simple data structures are used everywhere, and the emphasis is always on clarity, not efficiency or flexibility.

  • kbumsik 5 years ago

    I took a OS class with Xv6. As a Linux kernel dev I can tell you Xv6 is great for teaching OS than Linux.

    1. I remember the first assignment if the class was adding a new syscall. It was quite trivial task for Xv6 because Xv6 syscall layers is thin and it implements only < 30 simple syscalls. Imagine you are going to add a Linux syscall out of > 300 syscalls.

    2. Production grade kernels like Linux is very hard to read for students because they support additional configurations which, for example, are wrapped by a lot of #ifdef macros. Also there are overwhelming number of Arch/hardware support that are not needed for teaching.

  • monocasa 5 years ago

    It's absolutely tiny for one. It has less code than sel4, despite also including a userland and being a monlithic kernel.

    It's essientially a stripped down rewrite of what existed in Lion's Commentary on Unix. When you reduce subsystems to around 1KLOC each, it's a lot easier to see the core of what they're trying accomplish.

    As for what's missing... a lot. No threads, no mmap (or any way to share memory between processes), only vga, serial, lbs, and ide drivers (in the x86 port), no block devices in the fs, 20 something syscalls total.

alexellisuk 5 years ago

Great excuse to rewrite user-space utilities - https://github.com/mit-pdos/xv6-riscv/tree/riscv/user

jeffrallen 5 years ago

Xv6 is great, I taught an OS course on it at my employer once. One of my colleagues manned to creat a /dev/audio for it and play an MP3.

Rotten194 5 years ago

If you're interested, I wrote a blog post a few years ago about how to implement a syscall (getcwd) on Xv6: https://vgel.me/posts/pwd_command_xv6/

jjice 5 years ago

My OS class that I'm currently taking sues Xv6 as a base for learning about OS implementation. The documentation is great and it clocks in under 10K lines if I'm remembering correctly. I'm really enjoyed working with it in class so far.

ngcc_hk 5 years ago

Can it work with fpga etc. so still learning but one learn more. Also with general pin in out more scope. Not just IT

axblount 5 years ago

Are there any other good minimal teaching operating systems out there? Unix-like or not.

  • guerrilla 5 years ago

    MINIX before version 3. There are books by Tanenbaum (and I think others?) that use it to teach operating system design and development.

    • cxr 5 years ago

      Even Minix 3 is fairly small. "Operating Systems: Design and Implementation" was synced with Minix 3 in its latest edition (2006). It's all the crud in later releases where things started getting junked up, after Tanenbaum got a windfall of cash, gave his students the keys to the kingdom, so they ended up importing large parts of NetBSD, sloppily. Say hello to 3-hour build times and a codebase that no one contributes to anymore.

      • vips7L 5 years ago

        Yeah after I read OSTEP and felt like I understood xv6 enough I tried to move on to minix 3 and reading tanenbaums book. I couldn't do it. There was just so much going on.

  • harry8 5 years ago
  • loeg 5 years ago

    Windows NT was used in my university's Operating System course (in 2010).

qntty 5 years ago

Looks like this was recently re-written for RISC-V. Maybe it should be called Rv6 now.

loeg 5 years ago

Formerly:

https://news.ycombinator.com/item?id=22511569

https://news.ycombinator.com/item?id=17592560

https://news.ycombinator.com/item?id=10566312

https://news.ycombinator.com/item?id=7558081

https://news.ycombinator.com/item?id=6971127

https://news.ycombinator.com/item?id=3753216

https://news.ycombinator.com/item?id=2335824

  • alexellisuk 5 years ago

    Interesting, you'd think this didn't meet the "significant new development" criteria to be trending that many times.

    Also isn't stuff about UNIX popular?

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection