Learning operating system development using Linux kernel and Raspberry Pi(s-matyukevich.github.io) |
Learning operating system development using Linux kernel and Raspberry Pi(s-matyukevich.github.io) |
I think for educational purposes it will be very interesting and useful if someone develop from scratch a simple System V UNIX for RPi based on Bach's description in his seminal book on "The Design of the UNIX Operating System" [2]. The book also covers multi processors topic as supported by modern platforms such as RPi.
[1]https://www.arm.com/resources/education/books/operating-syst...
[2]https://github.com/suvratapte/Maurice-Bach-Notes/blob/master...
A few people seem to have ported xv6 to arm.
https://www.vitalsource.com/products/operating-systems-found...
I expect if I found a random piece of hardware that was close to an existing one that adding the driver, or updating things so that it worked on the new hardware would be possible. It's just not a situation I've come across.
What I found useful/educational was writing a simple linux security module.
1. LSMs are essentially isolated. 2. They don't care about hardware. 3. You can do lots of things with them. Even horrid evils things.
For example I put together the following module in which the kernel calls back to userspace every single time you execute a binary, to decide whether it should be permitted or not:
https://github.com/skx/linux-security-modules
(And yes, I appreciate that is almost exactly as horrid as it sounds! So much fun to hack around with though.)
Not OP but my perspective is that much of software development, engineering, and practices become cult like, often without theoretical or empirical basis.
I'm rarely surprised anymore when I see criticism of one approach over another. Someone may think "the way" to learn Linux kernel development isn't what OP suggested and there's a cult of people who agree who will adamantly concur to a fault.
https://www.raspberrypi.org/forums/viewtopic.php?f=117&t=275...
My OS course was hacking on x86 Linux in C. The C wasn't really the difficult part. Honestly, neither was the assembly, as most of was boilerplate: here's how you configure to registers for a system call, here's how you trigger the interrupt for the system call, here's how you get the return codes, etc.
I don't think the class would have been nearly as valuable if C were replaced with Python. At that point, so many of the interesting details would be hand-waved away that it wouldn't really be all that different from the other programming classes I took.
As to the inciting question, there is a Stonybrook OS course [0] designed around a java simulator that students implement modules for. Springer published M Kifer's book [1] about this OSP2 system. (The binaries are accessible via the link 'Students: Software Download'.) I'm of the impression that the course involves examining the trade-offs of each module. So the thread section spawns a bunch of request events per process for a module to deal with, whether with round robin or priority queues or whatever.
For real world learning, C is still what you want. It is one of the easier roads through.
However, here's a just few languages that can let you build a kernel up quickly:
+ Forth. It is well suited for the purpose. A tiny bit of assembly, and then just a bunch of definitions and you've built it all from the ground up. But if you think C is too complex for learning, then the idea of moving to a stack-based language could get in the way.
+ Lisp. The Symbolic Lisp machines might be in the past, but the various versions of Lisp are still flexible enough to let you build an OS, and lots of CS students do.
+ Lua. It is only slightly higher level than C, but with fun things like coroutines, hash tables, dynamic typing and GC. Due to its C99 nature and the desire to keep the language constrained, it runs on bare metal great. You don't have to modify Lua to run it baremetal on a Pi. [0]
If you are a solid programmer who already knows Python, learning C would only take 2-4 weeks. The benefit is worth the investment.
https://stackoverflow.com/questions/10904721/is-it-possible-...
Almost everything to do with kernels is about directly writing to memory addresses and ports and these things can't be done with a managed language, at least not without a significant runtime doing all the grunt work, at which point you'll need to understand much of the runtime's internals and at that point, you may as well have started out with a small C/C++/Rust kernel, plenty of which exist.
You could easily get a stripped-down interpreter or something running in that environment.
[0] https://pdos.csail.mit.edu/projects/biscuit.html [1] https://github.com/ffwff/lilith