Hello friends!
इस पोस्ट में Deadlock in Hindi – डेडलॉक क्या है? पूरी जानकारी के बारे में पूरी जानकारी आसान हिंदी भाषा में समझाई गई है।
यदि आप इस टॉपिक के बारे में जानना चाहते हैं, तो इस पोस्ट को पूरा जरूर पढ़ें।
Table of Contents
परिचय (Introduction)
Operating System में Deadlock एक महत्वपूर्ण concept है जो specially process management और resource allocation में आता है। जब दो या दो से ज्यादा processes एक-दूसरे की resources का इंतजार कर रहे होते हैं और कोई आगे नहीं बढ़ पाता, तो system deadlock में फंस जाता है।
इस article में हम विस्तार से समझेंगे:
- Deadlock क्या है
- Conditions required for deadlock
- Deadlock के types
- Deadlock prevention, avoidance, detection
- Real-life examples और OS में handling
Deadlock क्या है?
Deadlock तब होता है जब system के multiple processes resources के लिए एक-दूसरे का इंतजार करते हैं और कोई process complete नहीं हो पाता। इसे हम “Circular Waiting” की स्थिति भी कह सकते हैं।
Simple Example
मान लीजिए:
- Process A को resource R1 चाहिए और वह hold कर रहा है R2
- Process B को resource R2 चाहिए और वह hold कर रहा है R1
यह circular wait deadlock create कर देता है। दोनों processes hang हो जाती हैं।

Deadlock के चार Necessary Conditions (Coffman Conditions)
Deadlock तब ही occur होता है जब नीचे दिए गए चार conditions simultaneously satisfy हों:
- Mutual Exclusion (आपसी विलक्षणता)
- एक resource एक समय में केवल एक process के लिए available होना चाहिए।
- Hold and Wait (रोक कर प्रतीक्षा)
- Process कम से कम एक resource hold कर रहा हो और दूसरी resources के लिए wait कर रहा हो।
- No Preemption (Preemption नहीं हो सकता)
- Resource को जबरन remove नहीं किया जा सकता।
- Circular Wait (परिक्रामी प्रतीक्षा)
- Circular chain exist होना चाहिए जिसमें हर process अगले process से resource wait कर रहा हो।
Deadlock के प्रकार (Types of Deadlock)
1. Resource Deadlock
- Hardware या Software resources के लिए waiting
- Example: Printer, CPU cycles
2. Communication Deadlock
- Processes जब message या data के लिए wait करते हैं
- Example: IPC (Inter Process Communication) में message stuck होना
3. Combination Deadlock
- Resource + Communication दोनों involve
- Example: Distributed systems
Deadlock कैसे handle करें?
OS में Deadlock को handle करने के चार main strategies हैं:
1. Deadlock Prevention
Deadlock होने से पहले उसकी conditions को eliminate किया जाता है।
- Mutual exclusion को reduce करना
- Hold and wait को avoid करना
- Circular wait को break करना
2. Deadlock Avoidance
System safe state में रहे, इसके लिए resource allocation careful तरीके से किया जाता है।
- Banker’s Algorithm इसका best example है
- Before granting request, system check करता है कि safe state maintain रहेगा या नहीं
3. Deadlock Detection
अगर deadlock हो गया है तो detect करना
- Resource Allocation Graph (RAG) use होता है
- Cycle detect करने पर OS intervention करता है
4. Deadlock Recovery
- Processes kill करके या resources preempt करके recover करना
- Example: Abort process, Rollback operation
Real-Life Examples of Deadlock
- Dining Philosophers Problem
- Five philosophers sharing chopsticks, waiting circularly → deadlock
- Traffic Deadlock
- 4 cars intersection में एक-दूसरे का इंतजार कर रहे हों, stuck हो जाना
- Computer Systems
- Printer और scanner simultaneously request करना, process hang हो जाना
Deadlock in Modern Operating Systems
Modern OS जैसे Linux और Windows deadlock को detect और recover करने की techniques use करते हैं।
- Windows: OS scheduler और resource manager deadlock prevention implement करते हैं
- Linux: Kernel में deadlock detection mechanisms मौजूद हैं, specially IPC और file locks में
FAQs
Deadlock क्या होता है?
Deadlock वह स्थिति है जब दो या दो से ज्यादा processes resources के लिए एक-दूसरे का इंतजार करते हैं और system halt हो जाता है।
Deadlock के मुख्य चार conditions कौन-से हैं?
Mutual Exclusion, Hold and Wait, No Preemption, Circular Wait
Deadlock prevent कैसे किया जा सकता है?
Deadlock prevention techniques जैसे hold-and-wait elimination, circular wait break करना और careful resource allocation
निष्कर्ष (Conclusion)
Deadlock OS का एक critical concept है जो system efficiency और reliability को directly affect करता है। Understanding deadlock conditions, types और handling techniques operating system knowledge के लिए जरूरी है। अगर आप OS और process management अच्छे से सीखना चाहते हैं, तो Deadlock concept को अच्छी तरह समझना जरूरी है।