4.2.2 · HinglishOperating Systems

OS structure — monolithic, microkernel, hybrid

1,974 words9 min readRead in English

4.2.2 · Coding › Operating Systems


Woh ek idea jis par sab kuch tika hai: kernel mode vs user mode

Yahi ek tension teeno designs generate karti hai.


Monolithic kernel

KYA HAI: ek bada privileged executable (aur modern versions mein loadable modules bhi). SERVICES KAISE BAAT KARTI HAIN: direct function call — koi boundary crossing nahi. Examples: Linux, classic UNIX, BSD.

Downside: ek akela buggy driver kernel mode mein run karta hai → kuch bhi corrupt kar sakta hai → poora system crash. Bahut bada trusted code base.


Microkernel

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

Downside: saari woh IPC message-passing isse slower banati hai (historically Mach ki famous criticism).


Figure — OS structure — monolithic, microkernel, hybrid

Hybrid kernel

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


Trade-off, ek table mein

Property Monolithic Microkernel Hybrid
Services in kernel mode Sab 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: ek 12-saal ke bachche ko explain karo

Ek school ki kalpana karo. Principal sab kuch kar sakta hai — safe kholna, kuch bhi sign karna (yeh kernel mode hai). Students ko special cheezoon ke liye permission maangni padti hai (yeh user mode hai).

  • Monolithic = principal personally sab kuch karta hai — padhana, khana banana, pipes theek karna. Super fast (koi idhar-udhar poochhna nahi), lekin agar principal banana peel par fisal jaaye, toh poora school band ho jaata hai.
  • Microkernel = principal sirf chaabiyaan aur schedule rakhta hai; khana banana, padhana, plumbing alag staff karte hain jo aapas mein notes bhejte hain. Agar cook chod de, school chalta rehta hai — lekin saari woh note-passing slow hai.
  • Hybrid = zyaadatar alag staff, lekin principal personally sachchi urgent kaam handle karta hai time bachane ke liye.

Flashcards

Woh ek CPU feature kya hai jise "OS structure" actually organize kar raha hai?
Kaun si services kernel mode vs user mode mein chalti hain (privilege rings).
Monolithic kernel ko define karo.
Saari core OS services (scheduler, memory, FS, drivers, networking) kernel mode mein saath chalti hain, ek doosre ko direct function calls se call karti hain.
Monolithic kernel fast kyun hai?
Services ek address space share karti hain, isliye woh plain function calls se communicate karti hain — koi boundary crossings ya data copies nahi.
Microkernel ko define karo.
Sirf minimal services (IPC, scheduling, low-level memory) kernel mode mein chalti hain; FS, drivers, networking user-mode server processes ki tarah chalte hain.
Microkernel zyaada reliable kyun hai?
Services isolated user processes hain; agar ek crash ho toh kernel bachta hai aur use restart kar sakta hai. Trusted code base tiny hai.
Microkernel typically slower kyun hota hai?
Requests user/kernel boundary bahut baar cross karti hain IPC message-passing ke zariye; har crossing ek trap + context switch + copy ki cost lagaati hai.
Hybrid kernel ko define karo.
Microkernel-style modular design, lekin performance-critical services ko IPC overhead se bachne ke liye kernel space mein run kiya jaata hai.
Ek-ek example do: monolithic, microkernel, hybrid.
Monolithic = Linux; Microkernel = MINIX 3 / QNX; Hybrid = Windows NT / macOS.
Kya Linux ka module system ek microkernel feature hai?
Nahi. Loadable modules phir bhi kernel mode mein chalte hain (koi isolation nahi) → Linux monolithic rehta hai.
Communication-cost model aur yeh kya explain karta hai.
C ≈ n·s jahan n = boundary crossings, s = har crossing ki cost; explain karta hai ki microkernels (bada n) slower kyun hote hain.
Teeno structures ko speed aur reliability ke hisaab se order karo.
Speed: Monolithic > Hybrid > Microkernel. Reliability: Microkernel > Hybrid > Monolithic.
User se kernel mode mein switch kya trigger karta hai?
Ek system call / trap (ek controlled, hardware-enforced mode switch).

Connections

  • Kernel mode vs User mode — woh foundation jis par yeh poora topic tika hai
  • System calls and traps — woh mechanism jo boundary cross karta hai
  • Inter-process communication (IPC) — microkernel ki lifeblood aur bottleneck
  • Context switching — har crossing ki per-crossing cost ka hissa
  • Device drivers — classic example jo kernel mein (monolithic) vs user space (microkernel) mein rehta hai
  • Linux kernel modules — isolation ke bina modularity
  • 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