Operating System ka Overview
Operating System ka Overview
2. OS ke Main Functions:
🔹 Process Management: Multiple programs ko ek saath execute karne ka management karta
hai.
🔹 Memory Management: RAM ka efficient allocation aur deallocation karta hai.
🔹 File System Management: Data ko files aur directories ke form mein store aur manage karta
hai.
🔹 Device Management: Input/Output devices jaise ki keyboard, mouse, printer ka control karta
hai.
🔹 Security & Access Control: Unauthorized access aur viruses se system ko protect karta hai.
5. OS ke Importance:
🔸 Without OS, computer sirf ek hardware box hoga.
🔸 Software aur applications ko efficiently run karne me madad karta hai.
🔸 User-friendly interface provide karta hai.
UNIX aur Linux ek multi-user, multi-tasking operating system hain jo stability, security, aur
flexibility ke liye jane jate hain. Inka architecture modular hota hai, jo OS ke different
components ko efficiently manage karta hai.
🔹 UNIX/Linux Architecture ke Main Layers
1️ Hardware Layer
2️ Kernel Layer
3️ Shell Layer
4️ Application Layer
✅ Is layer me CPU, Memory (RAM), Hard Disk, Input/Output Devices aate hain.
✅ Kernel isi hardware se interact karta hai aur system resources manage karta hai.
Process Management – Programs (processes) ko create, execute aur terminate karta hai.
Memory Management – RAM ka efficient use karta hai.
File System Management – Files aur directories ka structure manage karta hai.
Device Management – Hardware devices ke liye drivers aur commands provide karta hai.
Security & Access Control – User authentication aur permissions handle karta hai.
🔹 Types of Kernels:
✅ Shell ek command-line interface (CLI) hota hai jo user aur kernel ke beech communication
establish karta hai.
✅ Yeh user ke commands ko samajh kar kernel tak pahunchata hai.
✅ Example:
Bash (Bourne Again Shell) – Sabse common shell (Linux me default).
Sh (Bourne Shell)
C Shell (csh)
Korn Shell (ksh)
Z Shell (zsh)
💻 Example Command:
ls -l
✅ Is layer me all user-level programs aate hain jo system pe run hote hain.
✅ Example:
💻 Example Command:
🔹 Why UNIX/Linux?
UNIX/Linux ek powerful aur secure operating system hai jisme Kernel, Services, System Calls,
aur System Programs ka important role hota hai. Chaliye inko detail me samajhte hain!
Kernel UNIX/Linux ka sabse important part hai jo hardware aur software applications ke
beech mediator ka kaam karta hai. Yeh system resources (CPU, Memory, I/O Devices) ko
manage karta hai.
Types of Kernel:
1️Monolithic Kernel – Pura OS ek hi kernel me hota hai (e.g., Linux).
2️Microkernel – Sirf essential features kernel me hote hain, baaki modules alag hote hain.
3️Hybrid Kernel – Monolithic + Microkernel ka mix (e.g., Windows NT, macOS).
Kernel users aur applications ko different system services provide karta hai jo system ki smooth
working ke liye zaroori hote hain.
System Calls ek interface hote hain jo user programs aur kernel ke beech communication
establish karte hain. Jab bhi koi user ya program system resources use karna chahta hai, toh woh
system calls ka use karta hai.
int main() {
printf("Process ID: %d\n", getpid()); // getpid() ek system call hai jo
process ID return karta hai
return 0;
}
🔹 4. System Programs (Utilities for Users)
System Programs wo high-level utilities hote hain jo users aur administrators system ko manage
karne ke liye use karte hain.
Example Commands:
ls -l
ps aux
free -m
🔹 Summary Table
Concept Description
Kernel dwara provide kiye gaye system features (Process, Memory, Security,
Services
Networking)
System Calls User applications aur kernel ke beech interface (e.g., fork(), read(), write())
System Programs System ko manage karne wale utilities (e.g., ls, ps, kill, gcc)
Conclusion
✅ Kernel OS ka core hota hai jo hardware aur software ko control karta hai.
✅ Services users aur programs ko system ke different functionalities use karne dete hain.
✅ System Calls user applications aur kernel ke beech communication establish karte hain.
✅ System Programs system ko manage karne ke liye utilities provide karte hain.
Ek process ek running program ka instance hota hai. Jab ek program execute hota hai, toh wo ek
process ban jata hai. Isme do main cheezein hoti hain:
1. New: Jab ek process create hota hai, tab wo New state me hota hai.
2. Ready: Jab process execute hone ke liye ready hota hai, par CPU assign nahi hota.
3. Running: Jab CPU kisi ek process ko execute kar raha hota hai.
4. Waiting: Jab process kisi external resource (jaise I/O device) ka wait kar raha hota hai.
5. Terminated: Jab process ka execution complete ho jata hai ya koi error aa jata hai.
PCB ek important data structure hai jo OS dwara maintain kiya jata hai. Isme ye information hoti
hai:
Process Creation: fork() system call se ek naya process create hota hai.
Process Termination: exit() system call ek process ko terminate karta hai.
Process Suspension and Resumption: Kabhi-kabhi process ko temporarily suspend (pause) kiya
jata hai aur baad me resume kiya jata hai.
1. Shared Memory – Multiple processes ek shared memory segment use karte hain jisme data
share hota hai.
2. Message Passing – Processes ek doosre ko messages bhejte hain ek IPC mechanism ka use
karke.
Process scheduling ka kaam CPU ke resources ko efficiently allocate karna hota hai.
Types of Schedulers:
Long-Term Scheduler: Decide karta hai kaunse processes memory me load honge execution ke
liye.
Short-Term Scheduler (CPU Scheduler): Decide karta hai kaunsa process CPU execute karega.
Medium-Term Scheduler: Process swapping (suspend aur resume) manage karta hai.
1. FCFS (First Come First Serve): Jo process pehle aata hai, wahi pehle execute hota hai.
2. SJF (Shortest Job First): Sabse chhoti execution time wale process ko select karta hai.
3. Round Robin (RR): Har process ko ek fixed time slice milta hai execution ke liye.
4. Priority Scheduling: Process execution priority ke basis par hota hai.
2. Multithreaded Programming
2.1 Threads
Thread ek lightweight process hota hai jo ek process ke andar multiple tasks parallel execute
karne ki ability deta hai.
1. User-level Threads: Ye user libraries dwara manage kiye jate hain, OS inhe directly manage nahi
karta.
2. Kernel-level Threads: Ye directly OS dwara manage kiye jate hain.
3. Memory Management
Static Allocation: Memory compile-time par allocate hoti hai aur execution ke dauraan change
nahi hoti.
Dynamic Allocation: Memory runtime par allocate hoti hai aur execution ke dauraan badal sakti
hai.
3.2 Swapping
Swapping ek aisi technique hai jisme ek process ko temporarily RAM se disk me move kiya jata
hai aur wapas RAM me laaya jata hai jab execution ki zaroorat ho.
3.3 Paging
Paging ek memory management technique hai jisme memory ko fixed-size blocks me divide
kiya jata hai jinhe pages kehte hain. Page Table logical memory ko physical memory se map
karti hai.
3.4 Segmentation
Virtual memory ek technique hai jo ek system ko zyada memory use karne ki suvidha deti hai jo
physically available memory se zyada ho sakti hai. Isme Demand Paging ka use hota hai jisme
sirf zaroori pages RAM me load hote hain.
Page Fault: Jab ek required page memory me available nahi hota aur disk se lana padta hai.
Segmentation Fault: Jab ek process invalid memory location access karta hai.
Conclusion