7 ms·
Interesting. Not clear if they got the big lesson of QNX vs. Mach - scheduler and interprocess message coordination is crucial to microkernel performance. The r
by Animats 8y ago
Interesting. Not clear if they got the big lesson of QNX vs. Mach - scheduler and interprocess message coordination is crucial to microkernel performance. The relevant pages of their "book" are blank. I'm trying to find the interprocess communication primitives and can't. Anyone know where that's documented?
I notice they put an ELF loader for executables in the kernel. It's better to have the loader outside the kernel. See this Linux vulnerability.[1] They may get there; they don't have shared objects yet. QNX starts up new processes with a canned startup which links to a shared object to do the loading of the executable. So loading runs with the privileges of the thing being loaded, which is safe.
They put very few drivers in the kernel - just a serial console. That's good. Like QNX, the boot image contains user-level processes you want run at startup. So you don't need drivers in the kernel to get going. This is good for embedded applications. QNX comes with a boot image builder into which you put what's needed at startup. There's a set of services for disk-based systems which get you a UNIX desktop like environment. But for embedded use, you can build a diskless QNX image with much less.
One advantage of a small unchanging kernel is that it can be put in a boot ROM for the life of the machine. This is a win in embedded devices. Any updating is done by loading new processes in userland, not with some super-powerful low level thing that nobody understands and probably relies on security through obscurity.
[1] https://nvd.nist.gov/vuln/detail/CVE-2018-6924 https://nvd.nist.gov/vuln/detail/CVE-2018-6924
- saghm 8y ago> They may get there; they don't have shared objects yet. I'm a bit of a novice when it comes to operating system implementation, so I'm not sure if this is a naive question, but how big of a priority is this for an OS written in Rust? By default, Rust statically links everything besides things written in C/C++ (e.g. libc), so would static linking be sufficient for an OS designed to implement everything in Rust?
- nine_k 8y agoSo do you suggest that every executable on the system should be statically linked? (Early Unix was like this, too.) Rust is apparently capable of producing shared libraries: https://doc.rust-lang.org/cargo/reference/manifest.html#building-dynamic-or-static-libraries https://doc.rust-lang.org/cargo/reference/manifest.html#buil...
- saghm 8y agoI'm not suggesting anything, but more asking how feasible it is for a modern OS. Rust is definitely capable of producing dynamic libraries, but it just doesn't by default. Given that the Rust ecosystem tends to prefer static binaries, I was curious about whether something in the OS space would run into unique issues from this approach that wouldn't apply to the application development currently being done.
- amenghra 8y agoCall me crazy, but it would be nice if binaries were bundled with all their dependencies but then the OS maps identical files to the same memory region to save space+perf. You get the best of both worlds?
- dahfizz 8y agoThis is exactly the approach of newer application formats in the Linux world such as flatpak and snaps. The problem, though, is that all the libraries are duplicated on disk. Flatpak and snaps get around this by recognizing when there is a shared dependency and only downloading it once. But if you "bake in" all your dependecies into a single executable file, that would cause pretty significant inflation for program sizes. This may be less of an issue now as disk space gets cheaper and cheaper, but it still feels like a step in the wrong direction.
- wtetzner 8y agoIt would be cool to have a filesystem that unique'd storage of identical objects under the hood. E.g. even though the user sees a particular filename, it's actual stored using a SHA to detect duplicates. If you edit a file, it could do a copy-on-write, to ensure you're not inadvertently changing a different file.
- db48x 8y agoDeduplicating filesystems do exist; ZFS is one of the better examples. Of course, maintaining the indexes turns out to become a larger percentage of your cpu time, and those indexes have to live somewhere so they occupy a lot of memory. (You could reduce that impact by doing file-level rather than block -level deduplication, but then you also lose many of the benefits) If you want something that's higher level, there are tools like git annex that do this.
- ComputerGuru 8y agoZFS (and others) feature block-based deduplication, not rule-level deduplication which is cheap and fast (though less “effective”).
- adamson 8y agoThis might vary from OS to OS, but at least for many Unix-based systems, everything running in a kernel context shares the same address space, so shared libraries aren't that relevant. Shared libraries for user processes are still desirable for a variety of reasons (memory usage, not needing to reload shared libs into the cache after a context switch).
- tormeh 8y agoNote: libc is not a part of Redox's future. Instead, a rewrite in Rust (relibc) will be used: https://gitlab.redox-os.org/redox-os/relibc https://gitlab.redox-os.org/redox-os/relibc
- pjmlp 8y agoBack in the old days static linking was the only option available in most computer systems, even UNIX only got dynamic linking support during the mid-90's.
- Animats 8y agoHas anyone found the spec for inteprocess communication? It's a message-passing system; this must be written down somewhere.
- jackpot51 8y agoI am the creator of Redox, and I am glad to have this rundown. Yes, the design of the Redox kernel is such that the kernel can load any set of drivers from the initramfs, including being completely diskless. In order to make this easy, ELF loading is part of the kernel. Otherwise, the ELF loader would have to be loaded somehow. How does QNX solve this issue? I could see there being a simpler executable format, or maybe the loader could do what the kernel does and modify its own paging tables. With regards to the book, it was outlined by a contributor who is no longer part of the project, so it is likely to be restructured when there is time, and the sections may change. There are drivers for what are considered to be critical features for any userspace inside the kernel. This mainly means the interrupt controller, but has included a serial console for kernel debugging. This will be an optional component in the future.
- Animats 8y agoThe QNX boot image can contain user processes, including shared objects. So the shared object needed to load executables is loaded at boot time, but as a user shared object. Processes start up other processes by a fork-like operation which starts some stub which connects to the executable loader shared object, which loads the executable. So the kernel is not involved. This is not a sufficient justification for a whole shared object system. QNX, being a hard real time system, does not page at all. This has advantages. You never have to worry about something being paged out when you need it. Response is very consistent. That's worth considering. Really, you don't page in embedded, you don't page in mobile, and if you're paging on servers you're in big trouble. RAM is cheap. I'd suggest not putting in paging. How does message passing work? Can't find the docs.
- snvzz 8y agoseL4 has a guaranteed WCET. Did you make such a calculation for your microkernel?
- jackpot51 8y agoNo, but it would be interesting to look into