Loading...
Loading...
An Operating System is system software that manages hardware resources and provides services to user programs. It acts as an intermediary between user and hardware.
Functions of OS:
Types of OS:
| Aspect | Program | Process | |---|---|---| | Definition | Static code on disk | Running instance of program | | State | Passive | Active | | Memory | No allocation | Gets PCB, stack, heap | | Existence | Permanent | Temporary |
Process States:
New → Ready → Running → Waiting → Ready → Running → Terminated
↑__________________________|
(I/O complete → back to Ready)
PCB (Process Control Block): OS ka "student record" for each process. Contains: PID, Process state, CPU registers, Program counter, Memory info, I/O info, Scheduling priority
| Feature | Process | Thread | |---|---|---| | Memory | Separate address space | Shared within process | | Creation | Slower (fork syscall) | Faster | | Communication | IPC (pipes, sockets) | Shared memory | | Context Switch | Expensive | Cheaper | | Crash effect | Only that process | Can crash whole process |
Multithreading Benefits: Responsive UI, parallel computation, resource sharing, faster context switch.
Goal: Maximize CPU utilization, throughput. Minimize waiting time, turnaround time, response time.
Turnaround Time = Completion Time - Arrival Time
Waiting Time = Turnaround Time - Burst Time
Response Time = First Response - Arrival Time
1. FCFS (First Come First Served):
2. SJF (Shortest Job First):
3. SRTF (Shortest Remaining Time First):
4. Round Robin (RR):
Time Quantum (Q) = fixed time slice (e.g., 4ms)
Each process gets Q time, then goes to back of queue
Preemptive — good for time-sharing systems
5. Priority Scheduling:
6. Multilevel Queue:
Example — RR Calculation:
Processes: P1(burst=10), P2(burst=4), P3(burst=5) Q=3
Gantt Chart:
| P1(3) | P2(3) | P3(3) | P1(3) | P2(1) | P3(2) | P1(4) |
0 3 6 9 12 13 15 19
WT: P1=9, P2=6, P3=7 Avg WT = 7.33ms
Critical Section: Code where shared resources are accessed. Must ensure:
// Binary Semaphore (Mutex) — 0 or 1
// Counting Semaphore — non-negative integer
wait(S): // P operation — acquire
while (S <= 0) ; // busy wait
S--;
signal(S): // V operation — release
S++;
Producer-Consumer with Semaphore:
empty = n (buffer capacity)
full = 0
mutex = 1
Producer: Consumer:
wait(empty) wait(full)
wait(mutex) wait(mutex)
ADD item REMOVE item
signal(mutex) signal(mutex)
signal(full) signal(empty)
4 Necessary Conditions (Coffman Conditions):
Deadlock Handling:
Banker's Algorithm:
For each resource request:
1. Tentatively allocate
2. Check if safe state exists (all processes can finish)
3. If safe → grant; if unsafe → deny and wait
| Strategy | Idea | Problem | |---|---|---| | First Fit | Allocate first hole big enough | External fragmentation | | Best Fit | Smallest hole that fits | Slow, small leftover holes | | Worst Fit | Largest hole | Large leftovers, wastes memory |
Fragmentation:
Memory divided into fixed-size frames (physical) and pages (logical). Page Table maps logical → physical.
Logical Address = Page Number (p) + Page Offset (d)
Physical Address = Frame Number (f) + Offset (d)
Page Table Entry: Frame number + Valid bit + Protection bits
TLB (Translation Lookaside Buffer): Hardware cache for page table
TLB Hit → 1 memory access
TLB Miss → 2 memory accesses (page table + actual data)
Memory divided into variable-size segments (code, data, stack). Each has base + limit registers.
Physical Address = Base[segment] + Offset
Protection: Check offset < Limit
Page Fault: Required page not in RAM → OS loads it from disk.
Page Replacement Algorithms:
| Algorithm | Idea | Optimal? | |---|---|---| | FIFO | Replace oldest page | No — Belady's anomaly | | LRU | Replace least recently used | Near optimal, costly | | Optimal | Replace page not used longest in future | Optimal but not implementable | | LRU Approximation | Clock algorithm, reference bits | Practical |
Thrashing: Too many page faults, CPU spends more time in paging than execution.
File: Named collection of related data. Attributes: Name, Type, Size, Permissions, Timestamps.
File Operations: Create, Open, Read, Write, Seek, Close, Delete, Truncate
Directory Structure:
File Allocation Methods:
| Method | How | Pros | Cons | |---|---|---|---| | Contiguous | Blocks stored together | Fast sequential access | External fragmentation | | Linked | Each block → pointer to next | No fragmentation | Slow random access | | Indexed | Index block stores all pointers | Fast random access | Overhead for small files |
Disk Scheduling (to minimize seek time):
Process & Threads:
Scheduling: 9. CPU scheduling ki need kyon hai? 10. Preemptive aur Non-preemptive mein kya fark hai? 11. Round Robin mein time quantum choose kaise karte hain? 12. Starvation aur Aging kya hain? 13. SJF optimal kyon hai? 14. Convoy effect kab hota hai? 15. Real-time scheduling (EDF, RMS) kya hai?
Synchronization: 16. Race condition kya hai? 17. Mutex aur Semaphore mein fark? 18. Monitor kya hai? 19. Dining Philosophers problem solve kaise karte hain? 20. Deadlock aur Livelock mein fark? 21. Banker's algorithm kab use hota hai? 22. Circular wait kaise prevent karte hain?
Memory: 23. Virtual memory ki need kyon hai? 24. Paging aur Segmentation mein fark? 25. TLB kya hai, kyon zaroori hai? 26. Page fault kaise handle hota hai? 27. Belady's anomaly kya hai? 28. Thrashing kaise rokein? 29. Demand paging kya hai? 30. Copy-on-Write kya hai?
File System: 31. FAT, NTFS, ext4 mein kya difference hai? 32. Inode kya hai? 33. Hard link aur Soft link mein fark? 34. Journaling file system kyon zaroori hai? 35. RAID kya hai, RAID-0 vs RAID-1? 36. Mount kya hota hai?
I/O & Misc: 37. Spooling kya hai? 38. Buffering aur Caching mein fark? 39. DMA kya hai aur kyon fast hai? 40. System call kya hai, examples? 41. User mode aur Kernel mode mein kya fark? 42. Interrupt kya hai? 43. Microkernel vs Monolithic kernel? 44. Hypervisor kya hai? 45. Shell kya hai? 46. /proc filesystem kya hai? 47. Swap space kya hai? 48. Memory leak kya hai, kaise detect karte hain? 49. Busy waiting kyon bura hai? 50. Preemption kya hai, kab zaroori hai?
Complete OS notes for B.Tech IT Sem 4 with process lifecycle, CPU scheduling, memory management, deadlocks, file systems, and 50+ viva questions with answers.
56 pages · 2.8 MB · Updated 2026-03-11
Process ek independent program execution hai apne memory space ke saath. Thread ek process ke andar lightweight execution unit hai jo memory share karta hai. Ek process mein multiple threads ho sakte hain.
Jab 4 conditions ek saath hon: Mutual Exclusion, Hold & Wait, No Preemption, Circular Wait. Koi bhi ek condition todne se deadlock prevent hota hai.
Virtual memory secondary storage (disk) ko RAM extend karne ke liye use karta hai. Processes ko lagta hai unke paas zyada RAM hai. Page fault tab aata hai jab required page RAM mein nahi hota.
Jab system itna zyada paging karta hai ki actual useful work kam ho jata hai. Bahut zyada page faults, CPU utilization girne lagta hai.
Mutex ek binary lock hai, sirf ek thread use kar sakta hai (ownership concept). Semaphore ek counter hai, signaling ke liye use hota hai, ownership nahi hoti.
Computer Networks Notes — B.Tech IT Sem 4
Computer Networks
Digital Electronics — Complete Notes IT Sem 1
Digital Electronics
Java Programming — Complete Notes for B.Tech IT Semester 3
Java Programming
Web Technologies — HTML, CSS, JavaScript, Node.js Complete Notes
Web Technologies
Cloud Computing Notes — B.Tech IT Sem 5
Cloud Computing
Your feedback helps us improve notes and tutorials.