Module Review: OS Foundations
Key Takeaways
- OS Duality: The OS has two jobs: Abstraction (API for apps) and Arbitration (Manager for hardware).
- Kernel Architecture:
- Monolithic: Everything in Kernel Space (Fast, Risky).
- Microkernel: Minimal Kernel, Drivers in User Space (Stable, Slow).
- Protection Rings:
- Ring 0 (Kernel): Absolute power.
- Ring 3 (User): Restricted access.
- CPL Register: The hardware enforcement mechanism.
- System Calls: The only way for User Space to talk to Kernel Space. Expensive due to Context Switches.
-
Boot Chain: Firmware (UEFI) → Bootloader (GRUB) → Kernel (
vmlinuz) → Init (Systemd).
Module Review: OS Foundations
[!NOTE] This module explores the core principles of Module Review: OS Foundations, deriving solutions from first principles and hardware constraints to build world-class, production-ready expertise.
1. Cheat Sheet
| Concept | Description | Command/Tool |
|---|---|---|
| System Call | Request kernel service (e.g., read, write) |
strace -p <pid> |
| Context Switch | CPU saving state to switch processes | vmstat 1 |
| Kernel Ring | Ring 0 (Privileged Mode) | dmesg (Kernel Logs) |
| User Ring | Ring 3 (Restricted Mode) | ps aux |
| PID 1 | The first process (init or systemd) |
systemctl status |
| Bootloader | Loads the kernel into RAM | update-grub |
2. Flashcards
Test your understanding. Click to flip.
🛡️
What happens if Ring 3 code executes 'CLI'?
General Protection Fault (GPF)
The CPU checks CPL. If CPL ≠ 0, it triggers an exception. The OS catches this and kills the process.
🐌
Why are Microkernels slower than Monolithic?
IPC Overhead
Components (like FS and Network) run as separate processes. Communication requires message passing and context switches.
📞
How does an App ask the Disk for data?
System Call
The app executes a SYSCALL instruction (trap). The CPU switches to Ring 0 and jumps to the kernel's handler.
🚀
What is the first process started by the Kernel?
Init (PID 1)
Usually /sbin/init, which is often a symlink to Systemd. It starts all other user-space services.