Part 7 of 8 · 3 min read
Trade-offs
Choosing a design
Think of choosing a vehicle. A sports car is fast and carries little, a lorry carries much and is slow, and no vehicle wins on every measure. Kernel designs are chosen in the same way. The analogy stops in one place: a buyer picks one vehicle, and one kernel can mix designs.
In plain words: No design wins on every goal. Monolithic kernels are fastest, microkernels are safest from faults and easiest to change, and layered systems are easy to build. General-purpose systems chose speed, and modules give back some flexibility. Where a fault must not be fatal, more code is moved out of kernel mode.
No design wins on every goal from page 1. The table summarises the trade-offs.
| Design | Speed | Safety from faults | Ease of change | Used by |
|---|---|---|---|---|
| Monolithic | Highest | Low: one bug can crash the kernel | Low: tightly coupled | Original Unix |
| Layered | Lower: many boundaries | Medium | High at design time | Some research systems |
| Microkernel | Lower: messages | High: servers fail alone | High | QNX, Mach |
| Modules | High | Low to medium | High: add and remove at run time | Linux, Windows, macOS |
| Hybrid | High to medium | Medium | Medium | Windows, macOS, Android |
In practice, speed has won for general-purpose systems, and modules recover the flexibility. Where a fault must not bring everything down, as in cars or aircraft, microkernels are common.
Where the line is drawn also affects security. Code in kernel mode has full power, so every driver there is part of the "trusted base". A smaller trusted base means fewer places for an attacker to find a flaw.
Read it as
Each design moves the boundary between "inside the kernel" and "outside". Inside is fast and dangerous. Outside is safe and slower.
Interview angle
Answer in your head first, then open it.
Monolithic versus microkernel?
A monolithic kernel runs all services in one address space and is fast but less isolated. A microkernel runs most services in user mode and passes messages, so it isolates faults but pays for message passing.
Is Linux a microkernel?
No. It is monolithic, with loadable modules.
Why modules?
They add drivers and file systems at run time without rebuilding the kernel.
What is a hybrid kernel?
A design that mixes ideas, such as Windows or macOS.
Check yourself: 1. Which design suits a system where one failing driver must not crash everything? 2. Why did speed win for desktop and server systems? 3. What is the "trusted base"?
Words you will meet
| Word | Meaning |
|---|---|
| System program | A tool shipped with the OS that runs in user mode |
| Address space | The range of memory addresses a program can use |
| Message passing | Sending data between programs through the OS |
| Server (here) | A user-mode program that provides an OS service in a microkernel |
| Hybrid kernel | A kernel that mixes more than one design |
| Trusted base | The code that must be correct for the system to be secure |
Quick notes
- An OS offers services through system calls: programs, files, input and output, communication, error detection and resource sharing.
- A monolithic kernel is one program in one address space. It is fast and tightly coupled.
- A layered system lets each layer use only the layers below it.
- A microkernel keeps the minimum in kernel mode and runs services as programs that exchange messages.
- Loadable modules add kernel code to a running system. Most real kernels are hybrids.
- No design wins on every goal, so the choice is a trade-off.