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

The Kernel is the part of the OS that runs in Ring 0 (Privileged Mode). It has unlimited power. The question is: How much code should we put there?

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. If the WiFi driver crashes (dereferences a null pointer), the entire OS crashes (Kernel Panic / Blue Screen).

Diagram: Monolithic

USER SPACE Browser Shell KERNEL SPACE (RING 0) MONOLITHIC KERNEL (Scheduler + FS + Drivers + IPC)

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

USER SPACE App FS Server Net Driver USB Driver KERNEL SPACE Microkernel (IPC)

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!
Components
File System
WiFi Driver
Scheduler
User Space
Drop here for Stability
Kernel Space
Drop here for Speed

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.