Operating System
OS Part-1
OS Part-2
- File Concepts and Access methods
- Free Space Management and Allocation methods
- Directory Systems and Protection
- File Organization, Sharing and Implementation issues
- Disk and Drum Scheduling
- I/O Devices Organisation & I/O Buffering
- I/O Hardware, Kernel I/O subsystem and Transforming I/O Requests to Hardware Operations
- Device Drivers and Path Management
- Device Driver Sub Modules and Procedure
- Device Scheduler and Handler
- Interrupt Service Routine (ISR)
- File System in Linux and Windows
OS Part-3
- Process and Process Control Block(PCB)
- Process Scheduling( Preemptive and Non Preemptive)
- Scheduling Algorithms
- Algorithm Evaluation
- Multiple Processor Scheduling
- Real Time Scheduling
- Operations on Processes
- Threads
- Inter-Process Communication
- Precedence Graphs
- Critical Section Problem
- Semaphores
- Classical Problems of Synchronization
- DeadLock
- Deadlock Prevention and Avoidance
- Deadlock Detection and Recovery
- Process Management in Linux
OS Part-4
- Memory Hierarchy in OS
- Concepts of Memory Management
- MFT and MVT
- Logical and Physical Address Space
- Swapping
- Contiguous and Non Contiguous Memory Allocation
- Paging
- Segmentation
- Paging Combined with Segmentation
- Structure and Implementation of Page Table
- Virtual Memory in OS
- Cache Memory Organization
- Demand Paging
- Page Replacement Algorithms
- Allocation of Frames and Thrashing
- Demand Segmentation
OS Part-5
- Distributed Operating System: Introduction and Types
- Distributed OS: Design Issues
- Distributed OS: File System
- Distributed OS: Remote File Access
- Remote Procedure Call(RPC)
- Remote Method Invocation(RMI)
- Distributed Shared Memory
- Parallel Processing and Concurrent Programming
- Security and Threats Protection in Distributed OS
- Security Design Principles and Authentication in Distributed OS
- Sensor Network and Parallel OS
Allocation of Frames & Thrashing in Operating System
Introduction
Memory management ka ek important aspect frame allocation aur thrashing hai.
-
-> Frame Allocation: Ye decide karta hai ki process ko kitni memory (frames) assign ki jayegi.
-
-> Thrashing: Jab CPU ka zyada time page swapping me chala jata hai aur actual execution slow ho jati hai.
Agar memory properly allocate nahi ki jaye, to system thrashing ka shikar ho sakta hai!
Allocation of Frames
Paging system me memory ko small fixed-size blocks (frames) me divide kiya jata hai. Jab koi process execute hota hai, tab uske pages ko available frames me load kiya jata hai.
Frame Allocation ka goal:
-
-> Efficient memory utilization
-
-> Minimum page faults
-
-> Process execution ko optimize karna
Types of Frame Allocation Policies
Equal Allocation
-
Har process ko equal number of frames diye jate hain.
-
Agar total frames = 10 aur 2 processes hain, to har process ko 5 frames milenge.
Advantage: Simple aur easy to implement
Disadvantage: Agar ek process zyada memory demand kare aur doosra kam, tab bhi dono ko equal frames milenge → memory wastage ho sakti hai.
Proportional Allocation
-
Har process ko uski size ke basis par frames allocate kiye jate hain.
Advantage: Large processes ko zyada memory milti hai → better performance
Disadvantage: Small processes ke liye zyada memory allocate nahi hoti.
Example:
Maan lo total 100 frames available hain, aur
-
Process P1 = 200 KB
-
Process P2 = 300 KB
Total size = 200 + 300 = 500 KB
Frame allocation:
-
P1 ke liye: (200/500) × 100 = 40 frames
-
P2 ke liye: (300/500) × 100 = 60 frames
Priority-Based Allocation
-
Process ke priority ke basis par frames allocate hote hain.
-
Higher priority wale process ko zyada frames milte hain.
Advantage: Important processes ko better performance milti hai.
Disadvantage: Low priority wale processes starvation face kar sakte hain.
Global vs Local Allocation
Global Allocation: Process kisi bhi available free frame ko use kar sakta hai.
Local Allocation: Process sirf apne allocated frames ke andar page replace kar sakta hai.
Thrashing in Operating System
**Thrashing ek situation hai jisme CPU zyada time page swapping me spend karta hai aur actual execution slow ho jati hai.
Why Thrashing Occurs?
Jab process ko sufficient frames nahi milte, to continuous page faults hone lagte hain.
CPU baar-baar naye pages ko memory me swap karta hai, aur process execution slow ho jata hai.
Working of Thrashing
Jab CPU kisi page ko access karna chahta hai jo memory me available nahi hai, to page fault hota hai.
Agar page faults zyada hone lagte hain, to OS naye pages ko load karta hai aur purane pages ko replace karta hai.
Agar naye pages bhi jaldi replace ho jate hain, to process continuously page faults generate karta hai!
Ye cycle repeat hoti hai aur system slow ho jata hai.
Example:
-
Maan lo ek process ko 10 pages ki zaroorat hai, lekin sirf 4 frames available hain
-
Process baar-baar naye pages ko laata hai aur purane pages ko replace karta hai
-
CPU ka zyada time swapping me chala jata hai, aur execution slow ho jati hai
Result: CPU 100% busy hota hai, lekin effective work 0% hota hai!
How to Prevent Thrashing?
Working Set Model:
-
Process ka currently required pages ka set (Working Set) memory me rakha jaye.
-
Agar working set ke pages memory me hain, to page faults kam honge.
Page Fault Frequency (PFF) Algorithm:
-
Agar page faults high hain, to process ko zyada frames diye jaye.
-
Agar page faults kam hain, to extra frames kisi aur process ko de diye jaye.
Local Replacement Policy:
-
Process apne allocated frames ke andar hi page replace kare taaki doosre processes affect na ho.
Increase RAM:
-
Agar RAM zyada hogi, to page faults automatically reduce honge aur thrashing avoid hogi.
Conclusion
Frame allocation ka sahi selection system ki performance ko optimize karta hai.
Thrashing ek serious issue hai jo system performance ko drastically reduce kar sakta hai.
Working Set Model aur Page Fault Frequency ka use karke thrashing avoid ki ja sakti hai.