4.2.2Operating Systems

OS structure — monolithic, microkernel, hybrid

2,122 words10 min readdifficulty · medium

The one idea everything hangs on: kernel mode vs user mode

That single tension generates all three designs.


Monolithic kernel

WHAT: one big privileged executable (plus loadable modules in modern versions). HOW services talk: direct function call — no boundary crossing. Examples: Linux, classic UNIX, BSD.

Downside: a single buggy driver runs in kernel mode → it can corrupt anything → whole system crash. Huge trusted code base.


Microkernel

Examples: MINIX 3, QNX, L4, Mach (the research microkernel).

Downside: all that IPC message-passing makes it slower (historically the famous criticism of Mach).


Figure — OS structure — monolithic, microkernel, hybrid

Hybrid kernel

Examples: Windows NT family (Win 10/11), macOS / XNU (Mach microkernel + BSD monolithic chunk).


The trade-off, in one table

Property Monolithic Microkernel Hybrid
Services in kernel mode All Minimal (IPC, sched, mem) Core + hot-path
Communication Function call (fast) IPC messages (slow) Mix
Reliability / isolation Low (1 bug = crash) High (servers isolated) Medium
Trusted code base Large Tiny Medium
Speed Fastest Slowest In between
Examples Linux, UNIX MINIX 3, QNX, L4 Windows NT, macOS


Recall Feynman: explain it to a 12-year-old

Imagine a school. The principal can do anything — open the safe, sign anything (that's kernel mode). The students must ask permission for special stuff (that's user mode).

  • Monolithic = the principal personally does everything — teaching, cooking, fixing pipes. Super fast (no asking around), but if the principal slips on a banana peel, the whole school shuts down.
  • Microkernel = the principal only keeps the keys and the schedule; cooking, teaching, plumbing are done by separate staff who must send notes back and forth. If the cook quits, school continues — but all that note-passing is slow.
  • Hybrid = mostly separate staff, but the principal personally handles the really urgent jobs to save time.

Flashcards

What single CPU feature is "OS structure" really organizing?
Which services run in kernel mode vs user mode (privilege rings).
Define a monolithic kernel.
All core OS services (scheduler, memory, FS, drivers, networking) run together in kernel mode, calling each other as direct function calls.
Why is a monolithic kernel fast?
Services share one address space, so they communicate by plain function calls — no boundary crossings or data copies.
Define a microkernel.
Only minimal services (IPC, scheduling, low-level memory) run in kernel mode; FS, drivers, networking run as user-mode server processes.
Why is a microkernel more reliable?
Services are isolated user processes; if one crashes the kernel survives and can restart it. Trusted code base is tiny.
Why is a microkernel typically slower?
Requests cross the user/kernel boundary many times via IPC message-passing; each crossing costs a trap + context switch + copy.
Define a hybrid kernel.
Microkernel-style modular design, but performance-critical services are run in kernel space to avoid IPC overhead.
Give one example each: monolithic, microkernel, hybrid.
Monolithic = Linux; Microkernel = MINIX 3 / QNX; Hybrid = Windows NT / macOS.
Is Linux's module system a microkernel feature?
No. Loadable modules still run in kernel mode (no isolation) → Linux stays monolithic.
Communication-cost model and what it explains.
C ≈ n·s where n = boundary crossings, s = cost per crossing; explains why microkernels (large n) are slower.
Order the three structures by speed and by reliability.
Speed: Monolithic > Hybrid > Microkernel. Reliability: Microkernel > Hybrid > Monolithic.
What triggers a switch from user to kernel mode?
A system call / trap (a controlled, hardware-enforced mode switch).

Connections

  • Kernel mode vs User mode — the foundation this whole topic rests on
  • System calls and traps — the mechanism that crosses the boundary
  • Inter-process communication (IPC) — the microkernel's lifeblood and bottleneck
  • Context switching — part of the per-crossing cost ss
  • Device drivers — the classic example that lives in kernel (monolithic) vs user space (microkernel)
  • Linux kernel modules — modularity without isolation
  • Windows NT architecture & XNU macOS kernel — real hybrids

Concept Map

user asks kernel via

generates

more in kernel mode

more in user mode

compromise

all services in kernel

large trusted blob

services as user servers

constant IPC crossings

example

blends

blends

Privilege rings: kernel vs user mode

System call trap

Speed vs reliability tension

Monolithic kernel

Microkernel

Hybrid kernel

Fast: direct function calls

Reliable: isolated servers

Buggy driver crashes system

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Dekho, "OS structure" ka matlab sirf ek hi sawaal hai: kaunsa kaam kernel mode mein chalega aur kaunsa user mode mein. Kernel mode matlab full power — hardware ko directly chhoo sakta hai, lekin yahan ek bug poori machine crash kar de. User mode restricted hota hai, kuch bhi special karna ho to system call ke through kernel se permission maangni padti hai (ye boundary cross karna costly hota hai).

Monolithic (jaise Linux) — saara saamaan, scheduler, memory manager, file system, drivers, sab ek hi badi kernel blob mein. Aapas mein simple function call se baat karte hain, isliye bahut fast. Lekin ek driver kharaab hua to pura system gaya — reliability kam.

Microkernel (jaise MINIX 3, QNX) — kernel mein sirf bare minimum: IPC, scheduling, basic memory. File system aur drivers sab user mode mein alag server processes ban jaate hain. Agar file system server crash ho jaaye, kernel zinda rehta hai aur usko restart kar deta hai — bahut reliable. Problem ye ki har request ke liye baar baar boundary cross karke message bhejna padta hai (IPC), isliye slow.

Hybrid (Windows NT, macOS) — bich ka raasta. Design microkernel jaisa modular, lekin jo services speed ke liye critical hain (file system, graphics) unhe wapas kernel mode mein daal diya taaki IPC ka overhead bach jaaye. Yaad rakhne ka formula: cost CnsC \approx n \cdot s, jahan nn = kitni baar boundary cross hui. Monolithic mein nn chhota, microkernel mein bada — bas yahi poori speed ki kahani hai. Speed: Mono > Hybrid > Micro; reliability ulta.

Go deeper — visual, from zero

Test yourself — Operating Systems

Connections