L4 micro-kernel

Classic Micro-kernel

Micro-kernel is OS at user-level. Before L4, a classic first generation micro-kernel moves to user level as much as possible. The disadvantage is that the overhead.

3 arguments

  • Native OS (Linux) performance on μ\mu-kernel.
  • Easier to debug in user-level process.
  • Co-located OS. (If well implemented, the performance of OS on top of micro-kernel will be no worse than co-located OS)
  • Specialized extensibility.
  • 100% binary compatibility.

μ\mu-kernel abstraction

It is smaller than a full-fledged OS, including these:

Threads -> CPU

User Process is implemented as an L4 task. The Linux server creates these tasks and specifies itself as their associated pager.

Address Space -> Mem

The server first requests memory from is underlying pager. The server then acts as a pager for the user processes it creates.

IPC -> Communication

OS

OS becomes a process in user-level. From SE view of portability, μ\mu-kernel is another layer of VM. It can run multiple OS on top of μ\mu-kernel.

For L4 Linux, the Linux kernel is implemented as a Linux Server. It manages all the address space, and then acts as a pager for the user processes it creates.

System call

L4 system calls are implemented using remote procedure calls, i.e. IPCs between the user processes and the Linux server. There are three different ways to make system call work.

Modify the libc.so

Shared lib needs to be recompiled, and all the system calls will be transformed into an IPC sending to the Linux server. There is no need to recompile the app.

Modify the libc.a

A modified version of libc.a, then recompile the app with the new libc.

Trampoline

A user-level exception handler, which emulates the native system-call trap instruction by calling a corresponding routine in the modified shared library. There is performance overhead.

Exception / H/W interruption

μ\mu-kernel maps hardware interrupts to message. The Linux top-half interrupt handlers are implemented as threads waiting for such messagees, one thread per interrupt source. Another thread executes all bottom haves once the pending top halves have been completed.

Page fault

Linux server manages physical memory. User process is a child of Linux server process. Linux server decides memory partition.

Whenever a page fault occurs, L4 converts any Linux user-process page fault into an RPC to the Linux server. The server replies by mapping and/or unmapping one or more pages of its address space to/from the Linux user process.

Benchmark

Pipes

L4 pipes is a user-level pipe implementation that runs on bare L4, uses L4 IPC for communication, and needs no Linux kernel. There are three types tested in the benchmark.

  1. Asynchronous L4 pipe (blocking IPC + buffering and cross-address-space communication)
  2. Synchronous RPC (blocking IPC directly)
  3. Synchronous mapping RPC (Sender temporarily maps pages into the receiver's address space)

Cache partitioning

To reduce cache conflict, a pager on top of L4 can be used to partition the second-level cache between multiple real-time tasks and isolate real-time from timesharing applications.

Grafting

Grafting is downloading code from app into kernel to improve the performance.