Kernel Architecture
[!NOTE] This module explores the core principles of Kernel Architecture, deriving solutions from first principles and hardware constraints to build world-class, production-ready expertise.
1. The Core of the Beast
Think of an Operating System as a massive restaurant. The User Space is the dining area where customers (applications) make requests. The Kernel is the kitchen—running in Ring 0 (Privileged Mode) with unlimited access to ingredients (Hardware: CPU, Memory, Disk). The architectural question is: Should we have one massive, shared kitchen, or multiple specialized food trucks?
This design decision defines the architecture of the OS.
2. Monolithic Kernel (The Speed Demon)
Examples: Linux, BSD, MS-DOS.
In a Monolithic kernel, everything runs in Kernel Space.
- Process Scheduler? Kernel.
- Memory Manager? Kernel.
- File Systems? Kernel.
- Device Drivers (NVIDIA, WiFi)? Kernel.
Trade-offs
- Pros: Blazing Fast. Components communicate via function calls (nanoseconds).
- Cons: Fragile. Because everything shares the same memory space, a bug in any component brings down the whole system.
- War Story: In the early 2000s, Windows gained a reputation for the “Blue Screen of Death” (BSOD). Microsoft later revealed that over 70% of these crashes weren’t caused by the core Windows kernel, but by poorly written third-party graphics and network drivers running in Ring 0. If a Wi-Fi driver dereferences a null pointer, the entire OS halts.
Diagram: Monolithic
3. Microkernel (The Safe Haven)
Examples: Minix, Google Fuchsia (Zircon), QNX.
In a Microkernel, we keep the kernel tiny. We move almost everything to User Space as separate processes (servers).
- Kernel: Only IPC, Scheduling, and Basic MM.
- User Space: File System Server, Network Driver, Display Driver.
Trade-offs
- Pros: Indestructible. If the WiFi driver crashes, the OS just restarts that process. The Kernel stays alive.
- Cons: Slow. Components communicate via IPC (Inter-Process Communication) (Message Passing), which involves context switching and copying data.
Diagram: Microkernel
4. Hybrid Kernel (The Compromise)
Examples: Windows NT, macOS (XNU).
A marketing term for “Modified Monolithic”. They move some things out (like Window Managers), but keep most performance-critical drivers in the kernel.
5. Interactive: Kernel Architect
Design your own OS. Drag components to where they belong.
- Goal: Build a Microkernel. Move drivers to User Space!
6. Summary
- Monolithic: Big Kernel, Fast, Risky. (Linux)
- Microkernel: Small Kernel, Stable, Slow (IPC overhead). (Minix)
- Hybrid: Practical middle ground. (Windows/macOS)
Next, we explore how applications talk to the Kernel via System Calls.