Earlier quoted context omitted.
> Wouldn't you want to choose a more "clear" language Are you implying that another language would be more clear? Quite the opposite, C doesn't hide anything from you. When you want to understand what the computer is doing you can tell directly from the C code. Unlike other languages where you need to understand what the language is doing first, and only then can you understand the computer. There are time where "hid…
> C doesn't hide anything from you. Yes, it does. C hides cache, SIMD, registers, the stack (no multiple return values for you!), the details of the heap (malloc() either succeeds or fails, and you can't know what it's going to do until you call it), SMP, instruction-level parallelism, and the details of atomicity, all of which are relevant to OS programming. C is a nice language. Don't pretend it's how the hardware…
Xv6
41–50 of 53 posts
Re: Xv6
#42If it's only for education purposes, why C? Wouldn't you want to choose a more "clear" language to get the ideas across?
C is about as "clear" as one can get, other than assembly. Most other languages hide away implementation details that are critical to writing an operating system--how would you handle, say, interrupts?
In addition, you can annotate a protected object (essentially, a group of shared procedures protected by an implicit mutex) as being interrupt-safe, and then any access to that object will be automatically protected by the appropriate instructions.
Plus, if you're in a Posix environment, you can use the exact same mechanism for interrupt handling. It's all remarkably elegant.
Alas, like everything Ada, the documentation is opaque in the extreme, but:
https://www2.adacore.com/gap-static/GNAT_Book/html/aarm/AA-C...
Note that at the bottom they're defining a parameterised interrupt handler structure and then instantiating it multiple times on multiple IRQs, each of which is in its own isolation domain...
Re: Xv6
#43If it's only for education purposes, why C? Wouldn't you want to choose a more "clear" language to get the ideas across?
What language did you have in mind? It has to be suitable for writing an OS, so Java, python and what not are out. The project has been around for more than a decade so the language has to have had a stable v1 release more than 10 years ago. Also the original code you are working with is in C so you will need to translate it. C seems like a perfectly reasonable choice.
Re: Xv6
#44Re: Xv6
#45Re: Xv6
#46Grokking xv6: http://experiments.oskarth.com/unix00/
What is a shell and how does it work?: http://experiments.oskarth.com/unix01/
What's on the stack?: http://experiments.oskarth.com/unix02/ (video of tracing a system call from user space to kernel space and back: https://www.youtube.com/watch?v=TWksEdn5eoA)
Page tables and virtual memory: http://experiments.oskarth.com/unix03/
Locks and concurrency: http://experiments.oskarth.com/unix04/
A short overview of the file system: http://experiments.oskarth.com/unix05/
Grok LOC? http://experiments.oskarth.com/unix06/
It was a very educational experience for me, and I highly recommend the journey for other people.
Re: Xv6
#47You can find it here: https://github.com/NewbiZ/xv6
Considering the original build system, I think having a look at this just for the sake of the cleaner makefiles is worth it.
There is also a mailing list for xv6, to share its understanding: http://www.freelists.org/list/xv6
Re: Xv6
#48Earlier quoted context omitted.
So the ls and make and all those tools; where do they come from? Are they straight compiles using GNU gcc tools etc? I only ask because I have no idea how much is the kernel compared to everything else; and if it has its own custom compiler or whatever.
No, they are minimal versions written for the OS. Here is ls[0] and cat[1]. You can compile with GCC. [0] http://www.ccs.neu.edu/course/cs3650/unix-xv6/HTML/S/64.html [1] http://www.ccs.neu.edu/course/cs3650/unix-xv6/HTML/S/42.html
Re: Xv6
#49I took 828 and really enjoyed it. It was one of the best classes I took at MIT. The other OS for that class is JOS, which is the one you build through the labs. It's similarly simple to understand and not that long to build.
> I took 828 and really enjoyed it. It was one of the best classes I took at MIT. The other OS for that class is JOS, which is the one you build through the labs. It's similarly simple to understand and not that long to build. I'm not sure what I'm supposed to take away from your comment aside from "I went to MIT".
1. Class 828 was a really good class, best he took. Others might want to try it too!
2. There's another operating system that's used in the class called JOS you might like to check out also if you are into learning about operating systems.
2. b) JOS is similarly quite simple to understand and doesn't take that long to build. Try it out also.
Hope this is helpful!
Re: Xv6
#50A few months ago I went through xv6 on my own as an experiment in getting better at systems programming. I wrote a bunch of posts about it, in case people are interested: Grokking xv6: http://experiments.oskarth.com/unix00/ What is a shell and how does it work?: http://experiments.oskarth.com/unix01/ What's on the stack?: http://experiments.oskarth.com/unix02/ (video of tracing a system call from user space to kernel…
In your original post, you mention one of the goals being able to contribute a patch to a modern OS such as BSD or Linux. After your experiment, do you feel like this is the case?