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
Deadlock Detection aur Recovery – Operating System
Deadlock ek aisi situation hoti hai jisme ek ya zyada processes resources ke wait me atak jati hain aur kabhi complete nahi ho pati. Agar deadlock prevention aur avoidance techniques ka use nahi kiya gaya hai, toh system ko deadlock detect karna padta hai aur usse recover karna hota hai.
Deadlock Detection
Jab system me deadlock hone ka chance hota hai, toh system ek detection algorithm ka use karke check karta hai ki koi circular wait ho raha hai ya nahi.
Deadlock Detect Karne Ke Tarike
-
1. Resource Allocation Graph (RAG) Cycle Detection
-
2. Wait-For Graph (WFG) Method
-
3. Detection Algorithm for Multiple Instances
1. Resource Allocation Graph (RAG) Cycle Detection
Agar sirf ek instance per resource hai, toh Resource Allocation Graph (RAG) ka use karke cycle detection se deadlock detect kiya jata hai.
Example:
Agar P1 → R1 → P2 → R2 → P1 ka ek cycle ban raha hai, toh ye deadlock hai!
Diagram:
P1 → R1 → P2
↑ ↓
R2 ← P1
Cycle Present → Deadlock Confirmed
2. Wait-For Graph (WFG) Method
-
Jab sirf processes ka relation dekha jata hai (resources ko hata ke), toh usko Wait-For Graph (WFG) kehte hain.
-
Agar graph me cycle detect hota hai, toh deadlock confirm hota hai.
Example:
Agar P1 → P2 → P3 → P1 ek cycle me hai, toh system deadlock me hai.
Cycle Hai → Deadlock Confirm
Cycle Nahi Hai → Deadlock Nahi Hai
3. Detection Algorithm for Multiple Instances
Agar ek resource ke multiple instances available hain, toh ek matrix-based detection algorithm ka use kiya jata hai:
-
Available Matrix: Kaunse resources abhi available hain.
-
Allocation Matrix: Har process ke paas kaunse resources hain.
-
Request Matrix: Har process ko aur kitne resources chahiye.
Algorithm Steps:
-
1. Har process ke liye check karo ki kya uske required resources available hain.
-
2. Agar available hain, toh allocate karke process complete hone do.
-
3. Agar koi process complete nahi ho sakta, toh deadlock detect ho jayega.
Deadlock Recovery
Jab system detect kar leta hai ki deadlock ho gaya hai, toh system ko usse nikalne ke liye recovery techniques ka use karna padta hai.
Deadlock Recovery Ke Tarike:
-
1. Process Termination (Abort)
-
2. Resource Preemption (Forcibly Take Resources)
1. Process Termination (Abort)
System deadlock todne ke liye kuch processes ko forcefully terminate (kill) kar sakta hai.
Do Tarike:
-
Abort All Deadlocked Processes: Saare deadlocked processes ko terminate kar do.
-
Abort One by One: Ek-ek process ko terminate karke check karo ki deadlock khatam hua ya nahi.
Downside: Agar kisi important process ko terminate kiya gaya, toh data loss ho sakta hai.
2. Resource Preemption (Forcibly Take Resources)
-
System kuch resources ko zabardasti wapas le sakta hai aur kisi aur process ko de sakta hai.
-
Rollback: Agar kisi process ko resources nahi mile, toh usko pichle state par wapas le aaya jaye.
Steps:
-
1. Select Victim Process: Konsa process ka resource le sakte hain.
-
2. Rollback Process: Process ko pehle wale state me le jao.
-
3. Starvation Avoidance: Agar ek process baar-baar preempt hota hai, toh usko priority di jaye.
Example:
Agar ek printer P1 ke paas hai, aur P2 bhi printer maang raha hai, toh system P1 se printer wapas le sakta hai aur P2 ko de sakta hai.
Conclusion
Deadlock Detection system ko check karta hai ki koi process circular wait me fasa hai ya nahi.
Deadlock Recovery ke liye system process terminate kar sakta hai ya resources ko forcibly wapas le sakta hai.
Best Practice: Deadlock prevention techniques ka use karo taki detection aur recovery ki zaroorat hi na pade!