This book rocks! I took the OS class with Remzi’s wife my junior year and it was the one that made everything “click”, bridging the gap between the computer engineering/circuits and higher-level C code we otherwise did. OSTEP and Xv6 were really integral for understanding things inside and out because we had to implement what we learned about in class.
This is a really great book for anyone interested. My professor used this in place of the more traditional book by Tanenbaum. It's easy to read and provides good citations if you want to read more in-depth about a specific chapter.
While its available completely free online, I highly recommend anyone who plans on using the book in detail to purchase a printed copy on lulu, its pretty cheap and looks really nice
It's incredibly helpful to learn by example, in my opinion. My university course taught using Xv6 as well, and the exams often included a problem where you were asked to modify a portion of the code to change behavior in a particular way (we were also asked to have the entire code printed out for reference during the exam). Probably one of my favorite courses.
Aside from being small, Xv6 is a normal OS. MINIX was designed to chase the gravely ill-advised microkernel fad that took over academia. You can lump Xv6 in with Linux and BSD, while lumping MINIX in with GNU HURD. The trouble is that glue isn't free: breaking an OS down into simple parts doesn't make the OS simple; the resulting interactions between simple parts become complex.
Xv6 is also written in a more modern coding style, using stuff like C99 initializers. It runs on modern hardware, even supporting SMP.
Ah, I have fond memories of staring at pages of Xv6 code. I took the OS class, 6.828, which uses Xv6 as a reference, while an undergrad at MIT. While relatively simple compared to most anything else you could think up, it gave great insight and intuition into code style and idiomatic OS patterns for working on JOS, the more substantial OS you end up writing in that class.
IMHO the source code is an example of good C style, and certainly quite pleasant to read --- no excessive verbosity, gratuitous indirections, PretentiouslyCapitalisedObscenelyLongIdentifiers, unnecessarily huge indents, or any of the other annoyances I tend to find with more "modern" source code. With the exception of a few minor stylistic choices I would've done differently, it's extremely close to my preferred source style.
Unfortunate that it isn't quite completely C89 (in particular regarding placement of variable declarations), since C89 compilers are much simpler than C99 ones and otherwise a compiler course could've been created around writing a compiler (and assembler) that can compile itself, Xv6, and then itself run inside Xv6 --- to become a self-contained, self-bootstrapping OS.
I mean, it's basically licensed under MIT. If somebody really wants to do something with the OS, they can just go and fork it, then get everybody else to hack on that instead. Given upstream is dead, it shouldn't be too hard to gain traction.
Some "basic" (actually very involved, but the modern-day PC is hell) requirement to get it to run on physical hardware past 2020[1] is UEFI support. USB keyboard support is probably also a hard requirement nowadays and would basically require a full USB stack.
Rather than incorporate them into the software, small enhancements are the sort of thing the authors of the project would prefer to leave as exercises for students, I'm sure.
At a glance, the code seems reasonably well commented, but it definitely assumes some prior familiarity with x86 hardware. Do you have any specific questions?
Does anyone know how to extend xv6 with copy-on-write? I was implementing a multiprocessing lib based on xv6 but noticed a fork copied the entire parent page table.
I think it’s a matter of extending the page fault routine to check whether the missing page is flagged copy on write, but I wasn’t sure how to correctly track which source page it should be copied from. Every process has its own clone of the page table hierarchy, so how do you know which one to grab during the fault?
When you fork, your forked process get a copy of the parent's page table i.e. at this point it points to the same physical page for xyz address as the parent. There can be a metadata bit in the final PTE that says this page is COW (Copy on Write). For context, in a 32-bit system 2 Level page table with 4KB pages means only 20 bits are used in the final page table to get the page frame. There are 12 bits free for some metadata.
Your forked process already has the physical page frame number and the COW bit. If it's a write/modify on that page and the COW is set, your code should allocate a new physical page, copy the raw contents of the currently mapped physical page and then finally update the page table entry with this new physical page frame number. If you want an example with some numbers, I can reply further. Let me know :)
Made me laugh (thanks for that!), but in fairness, MINIX 3 was designed for actual usage and not just education. From Wikipedia [1]:
> Although it still serves as an example for the new edition of Tanenbaum and Woodhull's textbook, it is comprehensively redesigned to be "usable as a serious system on resource-limited and embedded computers and for applications requiring high reliability."
Wikipedia says that there's a least one company using it for an ARM TrustZone kernel[1], but I can't seem to verify that on the linked vendor's home page.
[+] [-] ArtWomb|7 years ago|reply
http://pages.cs.wisc.edu/~remzi/OSTEP/
[+] [-] goodells|7 years ago|reply
[+] [-] tdjones879|7 years ago|reply
[+] [-] sitzkrieg|7 years ago|reply
[+] [-] enitihas|7 years ago|reply
[+] [-] exist|7 years ago|reply
[+] [-] rdh|7 years ago|reply
[+] [-] ape4|7 years ago|reply
[+] [-] sk_hazratali|7 years ago|reply
[deleted]
[+] [-] KenoFischer|7 years ago|reply
[+] [-] sassy_samurai|7 years ago|reply
[+] [-] dwheeler|7 years ago|reply
[+] [-] burfog|7 years ago|reply
Xv6 is also written in a more modern coding style, using stuff like C99 initializers. It runs on modern hardware, even supporting SMP.
[+] [-] tonysdg|7 years ago|reply
[+] [-] sobraton|7 years ago|reply
xv6, on the other hand, is just bare kernel with no functional purpose.
[+] [-] unknown|7 years ago|reply
[deleted]
[+] [-] MisterTea|7 years ago|reply
[+] [-] pieterr|7 years ago|reply
[1] https://en.wikipedia.org/wiki/MINIX
[+] [-] Cursuviam|7 years ago|reply
[+] [-] TheAnig|7 years ago|reply
[+] [-] pinewurst|7 years ago|reply
[+] [-] joebergeron|7 years ago|reply
[+] [-] unknown|7 years ago|reply
[deleted]
[+] [-] lkurusa|7 years ago|reply
[+] [-] userbinator|7 years ago|reply
Unfortunate that it isn't quite completely C89 (in particular regarding placement of variable declarations), since C89 compilers are much simpler than C99 ones and otherwise a compiler course could've been created around writing a compiler (and assembler) that can compile itself, Xv6, and then itself run inside Xv6 --- to become a self-contained, self-bootstrapping OS.
[+] [-] wolfgke|7 years ago|reply
> https://github.com/mit-pdos/xv6-public/pulls
but the authors (probably because of lack of time and/or academic obligations) seem to ignore them.
[+] [-] beefhash|7 years ago|reply
Some "basic" (actually very involved, but the modern-day PC is hell) requirement to get it to run on physical hardware past 2020[1] is UEFI support. USB keyboard support is probably also a hard requirement nowadays and would basically require a full USB stack.
[1] https://arstechnica.com/gadgets/2017/11/intel-to-kill-off-th...
[+] [-] justin66|7 years ago|reply
[+] [-] sigjuice|7 years ago|reply
[+] [-] qntty|7 years ago|reply
[+] [-] teraflop|7 years ago|reply
If not, the OSDev.org wiki is a pretty good starting point: https://wiki.osdev.org/Expanded_Main_Page
[+] [-] jey|7 years ago|reply
[+] [-] jpeg_hero|7 years ago|reply
https://en.wikipedia.org/wiki/Not_Another_Completely_Heurist...
[+] [-] apengwin|7 years ago|reply
[+] [-] dev510213|7 years ago|reply
[+] [-] bitcoinmoney|7 years ago|reply
[+] [-] rijoja|7 years ago|reply
[+] [-] monocasa|7 years ago|reply
[+] [-] bitcoinmoney|7 years ago|reply
[+] [-] shawn|7 years ago|reply
I think it’s a matter of extending the page fault routine to check whether the missing page is flagged copy on write, but I wasn’t sure how to correctly track which source page it should be copied from. Every process has its own clone of the page table hierarchy, so how do you know which one to grab during the fault?
[+] [-] mav3rick|7 years ago|reply
Your forked process already has the physical page frame number and the COW bit. If it's a write/modify on that page and the COW is set, your code should allocate a new physical page, copy the raw contents of the currently mapped physical page and then finally update the page table entry with this new physical page frame number. If you want an example with some numbers, I can reply further. Let me know :)
[+] [-] wcr3|7 years ago|reply
[deleted]
[+] [-] deusofnull|7 years ago|reply
[+] [-] tonysdg|7 years ago|reply
> Although it still serves as an example for the new edition of Tanenbaum and Woodhull's textbook, it is comprehensively redesigned to be "usable as a serious system on resource-limited and embedded computers and for applications requiring high reliability."
[1]: https://en.wikipedia.org/wiki/MINIX_3#History
[+] [-] beefhash|7 years ago|reply
[1] https://en.wikipedia.org/wiki/Xv6#Production_Use
[+] [-] thrillgore|7 years ago|reply
[deleted]
[+] [-] fernly|7 years ago|reply
[1] https://github.com/mit-pdos/xv6-public
[+] [-] shawn|7 years ago|reply
Seems fine. It’s hardly worth noting. May as well write “Minor” and use your time more efficiently.
[+] [-] sigjuice|7 years ago|reply