OS chaar classes of resources control karta hai. Har jagah trick yeh hai ki multiplexing karo: ek physical cheez ko space ya time mein bahut saare users ke beech share karo.
OS har process ko ek chhota sa time slice (quantum) deta hai, phir ek hardware timer interrupt control waapis OS ko force karta hai, jo agle process ko choose karta hai. Isse ek single core par programs simultaneously chalne ka illusion banta hai.
Q: Tumhare paas ek single CPU core hai. Programs CPU-bound hain (almost no I/O, p≈0). Kya zyada programs run karne se CPU utilization improve hogi? Pehle predict karo, phir check karo.
Verify:U=1−pn. p≈0 ke saath, U≈1 already ek program ke saath hi. Extra programs koi utilization gain nahi dete (aur switching overhead add karte hain). Multiprogramming sirf tab help karta hai jab p bada ho (I/O-heavy). ✅
What are the two core roles of an operating system?
Resource manager (scarce hardware share karna) aur abstraction layer (hardware ko clean interfaces ke peeche chhupaana).
Define multiplexing and its two kinds.
Ek resource ko bahut saare users ke beech share karna; time multiplexing (baar baar turns lena) aur space multiplexing (simultaneously pieces mein baantna).
Why does the CPU appear to run many programs at once on one core?
Time multiplexing — chhote time slices aur timer interrupts processes ko itni tezi se switch karte hain ki humans perceive nahi kar paate.
What formula gives CPU utilization with n processes each idle fraction p in I/O?
U=1−pn, derive hota hai is probability se ki sab n ek saath wait karen pn hoti hai.
What is a system call?
Ek controlled entry point jisse ek program OS service request karta hai, user mode → kernel mode switch karte hue.
Why do we need user mode vs kernel mode?
Taaki untrusted programs privileged actions request kar sakein bina directly privileges haasil kiye, protection milti hai.
Give the OS abstraction for raw disk sectors.
File / filesystem.
Give the OS abstraction for physical RAM and CPU respectively.
Virtual memory/address space; aur process/thread.
Worst-case wait for a process in round-robin (n procs, quantum q)?
(n−1)q.
When does multiprogramming NOT improve utilization?
Jab processes CPU-bound hon (p ≈ 0); extra programs overhead add karte hain bina U badhaye.
Recall Feynman: ek 12-saal ke bachche ko explain karo
Computer ka brain (CPU) actually ek time par sirf ek chhoti si cheez kar sakta hai, lekin tum music, games, aur homework sab ek saath chahte ho. Operating System ek super-fast teacher ki tarah hai classroom mein: woh ek bachche ko split second ke liye bolne deta hai, phir agla, itna fast ki lagta hai sab ek saath bol rahe hain. Yeh bachcho ko ek doosre ka saman pakdne se bhi rokta hai (tumhara game tumhari bank app mein nahi jhank sakta). Aur yeh easy buttons deta hai — tum kaho "meri file save karo" aur teacher parde ke peeche saari boring machine ka kaam karta hai. Toh OS = fair sharer + helpful parda.