HACKER Q&A
📣 agomez314

Examples of Microkernels?


I'm reading through the MIT xv6 OS handbook and code (here: https://github.com/mit-pdos/xv6-riscv/) and they mention the fact that they created it as a monolithic kernel since most unix systems are monolithic. They then introduce the microkernel concept. Are there microkernel concepts out there (especially code) I can check out? I'm curious to see how userspace processes communicate to kernel processes to execute privileged actions.


  👤 GianFabien Accepted Answer ✓
[seL4][1] is a formally verified microKernel which is used by billions of smartphones as part of their baseband OS. The part which is completely separate from Android or iOS. [1]:http://sel4.systems/

👤 mkeeter
Hubris is a microkernel-ish OS for embedded systems, and has a bunch of documentation about its design:

https://hubris.oxide.computer/reference/

It's all open-source on Github:

https://github.com/oxidecomputer/hubris

(I work at Oxide, mostly using Hubris)


👤 bunnie
Xous [1][2] is an example of a microkernel written in Rust and inspired by QNX, that we are actively developing.

[1] https://betrusted.io/xous-book/ch00-00-introduction.html

[2] https://github.com/betrusted-io/xous-core


👤 smcn
MINIX 3 is the goto, I believe? At least it was when I was researching them.

https://git.minix3.org/index.cgi?p=minix.git

Happy to be wrong though, I'd like new code to look at.


👤 anentropic

👤 Retr0id
The Nintendo Switch runs a microkernel called "Horizon". It has been fully reverse-engineered, and a 1:1 open-source reimplementation exists: https://github.com/Atmosphere-NX/Atmosphere/tree/master/libr...

👤 gte525u
QNX's docs[1] are some of the easier ones to read. The neutrino kernel briefly had it's source code available.

[1] https://www.qnx.com/developers/docs/6.3.0SP3/neutrino/


👤 MisterTea
Plan 9 is a great example of a hybrid kernel that is very much in the spirit of a microkernel. It uses 9p as the foundation meaning the whole OS is based around a file-like message oriented RPC protocol. Every process has its own namespace and mount table so you implement security by limiting mounted resources to a child proc and its children. Since the 9p byte streams are processor agnostic you don't have endian or cross platform problems so you don't care about a remote machines architecture.

The source code is included by default so you can boot and jump right in. Code is very clean, minimal and approachable.

The reason why it is not a microkernel is because hardware drivers and some performance sensitive code such as ip, tls and graphics are in kernel. The rest, including on-disk file system (cwfs, fat, ext, etc), certain usb drivers, etc run in user space.

> I'm curious to see how userspace processes communicate to kernel processes to execute privileged actions.

You write and read messages to synthetic files served by the kernel. Kernel files are served via a special # prefix so they can be opened by any program locally. Since user space programs can speak 9p you don't need any special programs to make syscalls to talk to the kernel. e.g. to list disks served by the sd(3) driver run 'ls '#'S'

Everything is just messages. Even unix signals were replaced with notes. To send a note to a process all you do is 'echo hello >/proc/$pid/ctl' and in the program you register one or more note handlers that simply do a strcmp() and if the note matches a string you define then do something. (if you complain about /proc and never used plan 9 /proc then your argument is invalid.)

If you think about it, plan 9 is just a host for microservices.

I recommend using 9front to explore.


👤 nix23
The whole L4 family and MACH or Hurd ;) and maybe have a look at Genode where you can have ~7 kernels atm:

nova

okl4_x86

foc

fiasco

pistachio

linux

sel4

https://genode.org/documentation/components

Also QNX and RTEMS need's to be mentioned here.

And Helios/Ares-os:

https://sr.ht/~sircmpwn/helios/


👤 js8
I dare to say that MVS and its successors (OS/390, z/OS) are also, in some ways, microkernels. Sadly, I am not an OS expert to make a proper comparison.

But I think one of the main mechanisms is basically non-kernel services install their own system calls (SVCs) and this SVC will schedule a light-weight thread (SRB) in the requestor's address space.

There was an older book that described how to create a simple OS along similar lines to MVS, but I don't remember the name.



👤 mijoharas
I was about to say macOS uses a microkernel, but on checking it seems that it's hybrid. Also, the source isn't available, so might not be what you're looking for.

👤 themoonisachees
The nintendo 3DS (and i think the switch too) runs on a microkernel with userspace pretty much everything. The docs on it are all reverse-engineered, though.

👤 gnufx
http://www.microkernel.info/ probably should list some others mentioned here.

I've only glanced at it, but there's some teaching material from L4 land apparently in the usual excellent German technical English at https://tu-dresden.de/ing/informatik/sya/professur-fuer-betr...


👤 lockless176
Composite OS is an interesting research micro kernel. It has great resources to help you to dig into it and its underlying principles!

About page: https://composite.seas.gwu.edu/

GitHub: https://github.com/gwsystems/composite


👤 lproven
MkLinux for early PowerMacs ran Linux on top of Mach. https://en.wikipedia.org/wiki/MkLinux

OSF/1, the attempt at an industry standard next-gen Unix by what is now the Open Group, holders of the UNIX trademark, also ran on Mach. Only DEC shipped it, though. The filesystem is now FOSS but I don't think the rest of DEC's code was, sadly. https://en.wikipedia.org/wiki/OSF/1

Chorus is out there: https://en.wikipedia.org/wiki/ChorusOS

HelenOS, from the Charles University here in Prague where I write, is a FOSS microkernel OS. http://www.helenos.org/


👤 ignoramous
rcore-os [0] uses a rust-lang port of zircon [1], the kernel that fuschia-os uses. zircon isn't quite a microkernel, but is pretty close to one [2].

FreeRTOS [3] bundles in a microkernel [4].

Speaking of FreeRTOS, you may also be interested in Riot OS developer's blog entry on building a (micro?) kernel [5].

[0] https://github.com/rcore-os/rCore

[1] https://github.com/rcore-os/zCore

[2] https://archive.is/Y49Ih

[3] https://github.com/FreeRTOS/FreeRTOS-Kernel

[4] https://archive.is/u8Hsw

[5] https://archive.is/0MHF1


👤 cies
Mach (used by GNU Hurd) deserves a mention.


👤 snvzz
Gernot Heiser's blog[0] deserves a mention.

I read it chronologically. It was worth every minute.

0. https://microkerneldude.org/


👤 jerheinze
Here's one that is "production" ready: the Mirage-Firewall microkernel built using MirageOS and running on Qubes OS.[0] In general MirageOS allows you to:

> ... construct unikernels for secure, high-performance network applications across a variety of cloud computing and mobile platforms. Code can be developed on a normal OS such as Linux or macOS, and then compiled into a fully-standalone, specialised unikernel that runs under a Xen or KVM hypervisor.[1]

[0] : https://github.com/mirage/qubes-mirage-firewall

[1] : https://mirageos.org/


👤 forgotpwd16
There're a couple of microkernels you can check out: http://www.microkernel.info

👤 Dracophoenix
Amiga OS. It was and probably still is the only microkernel OS commercially available to the general public.

👤 iveqy
minix also needs a mention here. Part of Intel Management Engine and close ties to linux childhood.


👤 notorandit
Minix Forever