1.1.13 · HinglishHow Computers Work

Operating system role — resource manager, abstraction layer

2,097 words10 min readRead in English

1.1.13 · Coding › How Computers Work


WHAT hai ek Operating System?

Do pillars:

Role Yeh kya solve karta hai Example
Resource manager Bahut saare programs, limited hardware Chrome aur Spotify ke beech CPU schedule karna
Abstraction layer Hardware messy hai aur vary karta hai "Open a file" SSD, HDD, USB sab par kaam karta hai
Figure — Operating system role — resource manager, abstraction layer

WHY: OS ki zaroorat kyun hai?


HOW: Role 1 — Resource Manager

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.

CPU — time multiplexing (scheduling)

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.

Memory — space + time multiplexing

OS har process ko uska apna virtual address space deta hai aur track karta hai ki kaunse physical RAM frames free hain.

Disk, devices, time

OS disk access arbitrate karta hai, device drivers own karta hai, aur access meter karta hai (permissions) taaki ek user doosre ko trample na kare.


HOW: Role 2 — Abstraction Layer

OS physical nastiness ko clean conceptual objects se replace karta hai:

Raw hardware reality OS abstraction Program bas yeh kehta hai
Magnetic sectors / NAND blocks File / filesystem open("a.txt")
Physical RAM addresses, swapping Virtual memory / address space koi bhi address use karo
Ek CPU, registers, interrupts Process / thread "mera code run karo"
Ek port par voltage signals Device file / driver API write(socket, ...)

Forecast-then-Verify

Recall Answer padhne se pehle forecast karo

Q: Tumhare paas ek single CPU core hai. Programs CPU-bound hain (almost no I/O, ). Kya zyada programs run karne se CPU utilization improve hogi? Pehle predict karo, phir check karo.

Verify: . ke saath, 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 bada ho (I/O-heavy). ✅


Common Mistakes (Steel-man + Fix)


Flashcards

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?
, derive hota hai is probability se ki sab ek saath wait karen 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)?
.
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.

Connections

  • Processes and Threads — woh CPU abstraction jise OS schedule karta hai.
  • Virtual Memory — RAM abstraction aur space multiplexing.
  • System Calls and Kernel Mode — user↔kernel boundary.
  • CPU Scheduling — time multiplexing ke peeche algorithms.
  • File Systems — disk abstraction.
  • Interrupts and the Fetch-Execute Cycle — timer OS ko control kaise waapis karta hai.
  • Device Drivers — hardware diversity OS ke zariye chhupayi jaati hai.

Concept Map

sits between

manages

does job 1

does job 2

hides messy diverse

shares scarce

uses technique

take turns

split pieces

applied to

forced back by

worst wait = n-1 times q

Operating System

Hardware

Application Programs

Resource Manager

Abstraction Layer

Multiplexing

Time Multiplexing

Space Multiplexing

CPU Scheduling

Timer Interrupt