3 ms·
It has crossed my mind to wonder if one could obtain many benefits of microkernels while somehow leaning on something like the Rust type system to prove isolati
by jerf 11y ago
It has crossed my mind to wonder if one could obtain many benefits of microkernels while somehow leaning on something like the Rust type system to prove isolation. It seems to me one of the big practical things about microkernels is forcing you to isolate off the modules. In practice, when you do not force isolation, developers will always find reasons to violate the boundaries. Even very well meaning and very experienced ones will still tend to poke holes in, and this is one of those things where once you poke even tiny holes, the flood tends to come in. Thirty years ago, that level of isolation required OS-level enforcement if it was going to happen.
But today, that's not the only way to guarantee isolation. We may also be able to do it via type systems. If we could create things statically guaranteed to be isolated but not requiring actual context switches, it should be theoretically possible to create things that are structurally microkernels, but do not need internal context switches because isolation has been proved at a higher level. Or, arguably, in some sense this would be something that transcends both microkernels and monolithic kernels to become something not properly called either.
I'm sure there's many an i to be dotted and ts to be crossed before this would work, and you'd still probably want to work out a run-time loadable module which would probably make things interesting, you need a story for how a device driver can individually crash without bringing the whole process down (though since Linux can do it, presumably it is possible anyhow), and a whole bunch of things. But it does seem like an interesting opportunity for someone to make a kernel that is, well, not the same basic kernel the C type system naturally affords.
- nostrademons 11y agoThat idea is generally termed a neokernel: http://c2.com/cgi/wiki?NeoKernel http://c2.com/cgi/wiki?NeoKernel It's basically relying on the type system & safety mechanisms of the underlying programming language to enforce some of the isolation properties that an operating system is normally used for. The Lisp Machine was probably the most commercially successful example. Since neokernels typically require tight integration between the programming language and the kernel, there are also opportunities for efficiency gains, eg. in Lisp Machines the garbage collector was tightly integrated with virtual memory to prevent page thrashing on collection, or in modern languages you could replace the OS scheduler with promises or green threads. The biggest downside of it is that it requires tight coupling between the programming language and OS, such that you can only use a single programming language (or a family of related ones that all share a type system) for all programs on the box. Few programming languages are flexible enough for that. With the move to cloud computing and virtualization, this becomes more practical, but then that same trend is also driving interest in the unikernel/exokernel pairing. If you only run a single application on a virtualized box, why not program directly to the hardware?
- agumonkey 11y agoSimilarly people describe C as a form of virtual machine. You don't really write for the hardware but for the C semantics.
- dikaiosune 11y ago> The biggest downside of it is that it requires tight coupling between the programming language and OS, such that you can only use a single programming language (or a family of related ones that all share a type system) for all programs on the box. I would point out (from a relatively lay perspective) that while this isn't strictly the case in current popular kernels (Mach/OSX, Windows, Linux), it's still a pretty strong trend. These kernels (AFAIK) are implemented in C and have large ecosystems of C code orbiting them. As such there are many benefits to having a program written in C or at least speaking C's ABI and memory layout. Maybe I'm mistaking the causes for this situation, but most developers are effectively using something that is either C itself, written in C, or speaks C in some way (CPython, JVM, MRI/CRuby, Perl, are notables that are written in C as far as I know). I think that if a language is sufficiently high performance and general purpose, it's fine for it to be the "core" language that other languages are expected to interface with.
- CountSessine 11y agoApparently a lot of telephone switches used neokernels. Ericsson's AXE series telephone switches ran software written in their proprietary PLEX language, and the PLEX runtime and the AXE OS were basically the same thing. That helped reduce overhead for context switches between tasks: hardware address spaces didn't need to be switched, or even supported; the runtime handled task separation. Erlang was meant to fill this role in newer switches, but it looks like PLEX is still being developed and used.
- jerf 11y agoThank you for the term to go Google on. I had not heard it before. It seems to me that recent advances in this field ought to ease the restrictions of requiring the entire stack to be the same language. It seems like a Rust neokernel ought to be able to run other programs on top much like a conventional kernel does, context switches and all. I'm not too worried about userspace/kernel context switches... there's a security barrier there that still strikes me as a good idea. I'm OK with something that produces an artifact in the end that looks like a monolithic kernel, and can function like one, and is merely internally structured with all the discipline of a microkernel. If all kernel elements have to be Rust, well, I'm fine with that.