4 ms·
In terms of teaching fundamentals of operating system theory and systems programming, is there such a thing as an operating system kernel written in Python or s
by mikece 6y ago
In terms of teaching fundamentals of operating system theory and systems programming, is there such a thing as an operating system kernel written in Python or some language which is meant to be easy to hack on for educational purposes? I wonder how useful that would be for a CS student, taking the complexity of C, C++, or Rust out of the picture and just running a kernel in a VM for educational purposes.
- simion314 6y agoIMO this topic is entangled with hardware, the student needs to do a course in hardware and how CPUs work, do some simple assembly coding, after that C is a natural progression. If C is too complex for some students then system programming and OS development is not for them. For educational and getting started I think https://www.nand2tetris.org https://www.nand2tetris.org is a good source material, the complexity or real world stuff is missing there so you can focus on essentials.
- cwoolfe 6y agoC is a language which is closer to hardware than Python, so you'll find it to be the language of OS programming. In fact, Python is written in C. I think trying to do OS programming in Python would actually be more difficult than learning C. 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-to-create-an-operating-system-using-python https://stackoverflow.com/questions/10904721/is-it-possible-...
- DC-3 6y agoThere's no point abstracting away the nitty-gritty. OS dev is the nitty-gritty.
- lzlz 6y agoActually using C or C++ is the most straightforward painless way to learn kernel dev. C is not complex at all. What you need to learn first is something like what nand2tetris offers, at least the first part. Usually you will have to do some variation of nand2tetris in the first or second year of undergrad.
- glouwbug 6y agoCorrect. Try these two: https://github.com/DoctorWkt/acwj https://github.com/DoctorWkt/acwj https://github.com/cfenollosa/os-tutorial https://github.com/cfenollosa/os-tutorial
- shakna 6y agoThere are actually plenty of languages that can lead you down this path, including some designed for the purpose. 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] [0] http://lua-users.org/lists/lua-l/2020-01/msg00157.html http://lua-users.org/lists/lua-l/2020-01/msg00157.html
- Santosh83 6y agoYou could write a Java based virtual kernel designed to run within the JVM and manage child processes I suppose, but what is the real world utility of such a thing? 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.
- chillfox 6y agoI don't know of any specifically made for teaching, but there is biscuit made in Go[0] and Lilith made in Crystal[1]. [0] https://pdos.csail.mit.edu/projects/biscuit.html https://pdos.csail.mit.edu/projects/biscuit.html [1] https://github.com/ffwff/lilith https://github.com/ffwff/lilith
- vertex-four 6y agoDepending on what, exactly, you want to hack on, building components on top of seL4 could be a way to go. There's a large collection of libraries built on top of it, that you can replace as you feel like - https://docs.sel4.systems/projects/available-user-components.html https://docs.sel4.systems/projects/available-user-components... - and there's a few different options for communication between them (seL4's IPC, shared memory, etc). You could easily get a stripped-down interpreter or something running in that environment.
- mywittyname 6y agoAn OS course taught in Python is really just a data structures and algorithms course. When you ignore the hardware aspect, topics like scheduling and virtual memory management are about selecting an algorithm with the appropriate trade-offs. 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.
- Nzen 6y agoIf the language is boilerplate and the algorithms/data-structures derive from the physical constraints, was the OS course you completed mostly about hardware ? 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. [0] https://www3.cs.stonybrook.edu/~kifer/Courses/cse306/ https://www3.cs.stonybrook.edu/~kifer/Courses/cse306/ [1] https://www.springer.com/gp/book/9781846288425 https://www.springer.com/gp/book/9781846288425