7 ms·
Rewriting the Linux kernel in rust would be a rehash of why we ended up with Linux in the first place: rewriting an older OS from scratch. I would love to see
by jacquesm 5y ago
Rewriting the Linux kernel in rust would be a rehash of why we ended up with Linux in the first place: rewriting an older OS from scratch.
I would love to see a solid implementation of a real micro kernel based OS based on a message passing core in Rust to become a viable alternative to the now 50 year old Unix architecture. This would give us a possibility of some real progress on the security and process scheduling front, both of which are severely lacking in the Unix model.
- abendstolz 5y agoJust in case you don't know about it: https://redox-os.org/ https://redox-os.org/ could be interesting to you :)
- chasil 5y agoFuchsia and QNX provide a lot of what you want. https://en.wikipedia.org/wiki/QNX https://en.wikipedia.org/wiki/QNX https://en.wikipedia.org/wiki/Fuchsia_(operating_system) https://en.wikipedia.org/wiki/Fuchsia_(operating_system) https://lobste.rs/s/p8bizb/getting_know_fuchsia_google_s_open_source https://lobste.rs/s/p8bizb/getting_know_fuchsia_google_s_ope...
- jacquesm 5y agoI think I'm aware of QnX ;) (I wrote a clone).
- afr0ck 5y agoWhy do people implicitly assume that micro kernels are the best OS design? In fact, micro kernels have a lot of issues and limit the possibilities of what an OS can do! One of the most important issues is they prevents resource sharing in a rich and efficient way between the components of the kernel. They make building rich relationships between kernel data structures and kernel subsystems very messy, complicated, impracticable and very inefficient. Micro kernels are delusional and people should stop implicitly assuming their superiority.
- sumtechguy 5y agoMessage passing at first seems interesting and neat and useful. It is for some cases. But it comes at a cost of complexity and latency.
- PaulDavisThe1st 5y agoThis is a limitation of the memory model, not the microkernel. If you had a single hardware-protected address space, kernel modules could share resources freely. But this does argue against message passing, since such systems preferentially try to use messages over sharing whenever it's possible.
- elihu 5y agoHistorically, one of the main arguments against microkernels is that having a kernel that's broken up into a lot of threads that each have their own hardware-enforced memory protection and use message passing to communicate with each other is dreadfully inefficient. All those context switches are expensive, and copying all that data around when you send messages is expensive. Rust's memory model largely makes those isolated address spaces unnecessary, and sending a message at runtime basically amounts to copying a pointer. So, with these performance issues resolved, I think it makes sense to look at microkernels again. The reasons why Linus was opposed to writing Linux as a microkernel in the 90's don't necessarily still apply now in 2021. There may some things the Linux kernel does that can't be efficiently expressed using a message-passing style, but I don't know if that's actually true or not.
- adwn 5y ago> Rust's memory model largely makes those isolated address spaces unnecessary, I think you're confusing several concepts. Rust's "memory model" is the C++11 memory model. Maybe you meant the borrow checker and the distinction between shared and exclusive references? Yes, those make it much harder to accidentally screw up other parts of your address space, but it's downright trivial to do it on purpose – you just need an unsafe block and std::ptr::write. There's nothing about Rust that could replace isolated address spaces. Rust is typically compiled to native machine instructions, there's no sandbox or virtual machine that will protect different modules from each other.
- PaulDavisThe1st 5y agoMach's internals didn't follow the Unix model, and was by almost any metric a failure. There have been several other "real micro kernel based OS based on a message passing core", and they too, by almost any metric, have been a failure. Process scheduling in Linux in 2021 is far, far ahead of anything in any other OS, ukernel or MP-based. The idea that there hasn't been progress in this area is really completely absurd. In fact, the general idea that Linux follows "the now 50 year old Unix architecture" is also pushing the boundaries quite a lot.
- jacquesm 5y agoMeanwhile, the world runs on QnX. The fact that you don't realize it and don't see it is testimony to its success.
- PaulDavisThe1st 5y agoI know that QnX is widespread, but far more devices run Android than QnX. It's a bit of a philosophical debate whether the software that runs most smartphones "runs the world" more or less than the stuff covered by QnX, but I'd say that's its a bit of a stretch to just give the win to QnX :) But you're right, QnX is the one (probably the only?) micro-kernel that has seen widespread adoption. Almost all of it has been in the context of embedded systems, which doesn't invalidate the substantial success, but it does leave QnX as the exception that proves the rule. It also leaves QnX as yet another example of the general failure of microkernels as general purpose computing platforms. QnX design is excellent for the contexts where it is deployed, but there's a reason you don't run it on PCs, tablets, data crunchers, smartphones and many other sorts of computing contexts.
- jacquesm 5y agoLots of devices run on Android but that's because there isn't a valid alternative. QnX and it's brethren are used where failure is not an option. I used it daily on my PC for years and it was hands down the best environment I've used with distance (mostly compared to IRIX, Windows and Linux). Super responsive, never locks up, no weird delays it just works, 24x7, year after year. The whole throughput argument never worked anyway, that was just Linus talking about something that he didn't have direct experience with, it's latency that is far more important than raw throughput in interactive computing because interactive computing is a real time task.
- dnautics 5y agoI believe someone is building something like that on top of sel4, which gives even stronger correctness guarantees than Rust, even though it's C.
- pcwalton 5y agoWritten properly, a monolithic kernel in Rust would provide many of the benefits of a microkernel, due to the memory safety. It'd be much along the same lines as Microsoft Research's Midori, with software isolation instead of hardware isolation.
- jacquesm 5y agoIt would be wide open to specially crafted drivers, it's the equivalent of client side security (or maybe that should be 'compile time security'). Memory safety is something only process space isolation can bring.