Deadlock Avoidance In Operating System

Deadlock avoidance allows the three necessary conditions mutual exclusion , hold and wait , no preemption , but makes the judicious choice to assure that deadlock point is never reached. it means that avoidance allows more concurrency than prevention.

The basic idea for deadlock avoidance is to grant only those requests for available resources that can not possibly result in a state of deadlock. This strategy is implemented by having the resource allocator examine the effects of granting a particular request.

If granting of resources can not lead to deadlock, the resource is granted to the requestor. otherwise, the requesting process is suspended until such time when its pending request can be safely granted.

In order to evaluate the safelty of the individual states , deadlock avoidance requires all process to state their maximum number of resources of each type requirements prior to execution.

A deadlock avoidance algorithm dynamically examines the resource-allocation state to ensure that a circular wait condition can never exist. The resource allocation state is defined by the number of available and allocated resources, and the maximum demands of the process.

Safe and unsafe state: A state is safe if the system can allocate resources to each process in some order and avoid a deadlock. In other words, a system is in a safe state only if there exists a safe sequence.

A sequence of processes < p1, p2,….pn > is a safe sequence for the current allocation state if , for each pi , the resources that pi can request can be satisfied by the currently available resources plus the resources held by all the pj, where j<i. If no such sequence exist , then the system state is said to be unsafe.

A safe state is not a deadlock state. Conversely a deadlock state is an unsafe state. However, all unsafe states are no deadlocks.

In the case of any queries, you can write to us at we will get back to you ASAP.

Hope! you would have enjoyed this post about deadlock avoidance.

Please feel free to give your important feedbacks in the comment section below.

Have a great time! Sayonara!


Methods For Deadlock Prevention

Deadlock prevention is an approach used by designers in dealing with the problem of deadlock. The basic philosophy of deadlock prevention is to delay at least one of the four necessary conditions for deadlocks.

1. Mutual exclusion:

The mutual condition must hold for nonsharable resources, such as a printer that can not be simultaneously shared by several processes. On the other hand, sharable resources do not require mutually exclusive access and thus can not be involved in a deadlock. for example, read-only files can not be accessed simultaneously by several processes.

To prevent mutual exclusion, avoid assigning a resource when that is not absolutely necessary, and try to make sure that a few processes may claim the resource as possible as.

2. Hold and wait:

The hold and wait condition can be eliminated by forcing a process to release all resources held by it whenever it requests a resource that is not available. There are two protocols to implement this strategy

  • The process requests all needed resources before it begins execution. We can implement this provision by requiring that system calls requesting resources for a process procede all other system calls.
  • Second protocols allow a process to request resources only when the process has none. A process requests resources and use them. Before it can request any additional resources, however, it must release all the resources that are currently allocated.

These protocols have two main advantage:

  • Resource utilization may be slow, since many of the resources may be allocated but unused for a long period.
  • starvation is poosible.

3. No preemption:

This condition can be prevented using following protocols. If a process holding certain resources is denied a further request, that process must release its original resources, if necessary, request them again together with the additional resource.

Alternatively, if a process requests a resource that is currently held by another process, the operating system may preempt the second process and require it to release its resources and allocate them to the requesting process.

This latter scheme prevents deadlock only if no two processes processed the same priority.

This protocol is practical only when applied to resources whose start can be saved and restored later, such as CPU registers and memory space.

3. Circular wait:

The circular wait condition can be prevented by defining a linear ordering of resource types. If a process has been allocated resources of type R, then it may be subsequently request only those resources of types following R in the ordering.

A disadvantage of this approach is that resources must be acquired in the prescribed order as apposed to being requested when actually needed. This may cause some resources to be acquired in advance of their use, Thus lowering the degree of concurrency by making unused resources unavaliable for allocation to other processes.

In the case of any queries, you can write to us at we will get back to you ASAP.

Hope! you would have enjoyed this post about deadlock prevention methods.

Please feel free to give your important feedbacks in the comment section below.

Have a great time! Sayonara!


Methods For Deadlock Handling

There are three methods for deadlock handling:

  1. Ensuring that deadlock state will never occur – To make sure this condition there are two techniques used which is explained below:

Deadlock prevention:

In this scheme, deadlock is prevented by ensuring that at least one condition occurs out of four conditions (mutual exclusion, hold and wait, no preemption, circular wait) required for occurring deadlock state.

Deadlock avoidance:

This scheme requires additional information about how resources will be requested by a process in its lifetime. By this information, it takes a decision whether a resource should be allocated to the processor it should wait.
Here, all available resources are allocated currently and resources will be requested in the future are kept in the account.

2. After occuring deadlock:

In this system we allow the system to enter a deadlock state, detect it, and recover. In this enviroment the system can provide an algorithm that examine the state of the system to determine whether a deadlock has occurred, and an algorithm to recover from the deadlock.

3. Some system does not ensure that a deadlock will never occur.

And also does not provide a mechanism for deadlock detection and recovery, then we may arrive at a situation where the system is in deadlock state yet has no way of recognizing what has happened.

This method is not viable, approach to the deadlock problem, however, in many system deadlock occur infrequently, once per year, thus this method is cheaper than the costly deadlock prevention, deadlock-avoidance, or deadlock detection and recovery methods that must be used constantly. Also, in some circumstances the system is in a frozen state but not in a deadlock state.

In the case of any queries, you can write to us at we will get back to you ASAP.

Hope! you would have enjoyed this post about deadlock handling.

Please feel free to give your important feedbacks in the comment section below.

Have a great time! Sayonara!


Deadlock in the distributed operating system in Hindi? डैडलॉक क्या होता है?

हेलो दोस्तों, आज के इस ब्लॉग में मै आपको डिस्ट्रिब्यूटेड ऑपरेटिंग सिस्टम में होने वाले Deadlock के बारे में बताने जा रहा हूँ | डिस्ट्रिब्यूटेड सिस्टम में deadlock कुछ उसी प्रकार होता है, जैसा कि सिंगल प्रोसेसर सिस्टम में होता है | बस इसमें सबसे बड़ी दिक्कत जो होती है, वो ये होती है कि, इन्हे अवॉयड, prevent और detect करना कठिन होता है | और अगर हमें डेडलॉक के बारे में पता भी चल जाता है तो इसे cure करना बड़ा मुश्किल होता है, क्योकि साडी relevant इनफार्मेशन कई मशीनो में फ़ैल चुकी होती है |

सबसे पहले जो लोग Deadlock नहीं समझते वो समझते वो समझ ले कि डेडलॉक आखिर होता क्या है ?

इस Deadlock को हम बहुत ही सिंपल example से समझते है| deadlock उत्पन्न होता है डिपेंडेंसी के कारण, अगर आप को किसी काम को करने के लिए किसी वस्तु या औजार कि जरुरत है और वो वस्तु और औज़ार किसी और के पास हो तो फिर इस सिचुएशन को deadlock बोलेंगे, क्योकि यहाँ आप का काम एक रिसोर्स पर देपेंद कर गया है जो कि किसी और के पास है | जिस तरह नए घर के निर्माण के समय जब तक छत के लैंटर के लिए बेस नहीं बनता तब तक लाइट वाला लाइट के पाइप नहीं बिछा पता| इस तरह से लाइट वाला depend हो जाता है कारीगर पर|

कुछ लोग इस डिस्ट्रिब्यूटेड Deadlock को दो भागो में बाँट कर देखते है | एक है communication deadlock एंड सेकंड इस resource Deadlock . कम्युनिकेशन Deadlock होने का सिनेरियो देखते है, जब कोई प्रोसेस A प्रोसेस B को मैसेज सेंड करने कि कोशिश कर रही और प्रोसेस B प्रोसेस C को मैसेज भेजने कि कोशिश कर रही है और प्रोसेस C प्रोसेस A को मैसेज भेजने की कोशिश कर रही है | और इस कारण से यहाँ deadlock की सिचुएशन क्रिएट हो जाती है |

और एक resource Deadlock तब होता है जब कोई कुछ प्रोसेसेज किसी I/O डिवाइस , फाइल्स , लॉक्स या अन्य कोई और रिसोर्सेज को यूज करने के लिए लड़ती रहती है |

Deadlock को हैंडल करने के लिए 4 रणनीति निम्नलिख्ति है |

The ostrich algorithm (Ignore the problem )
Detection (allow deadlock to occur, detect them, try to recover)
Prebention (statically make deadlock structurally impossible)
Avoidance(Avoid deadlock by allocating resource carefully)

ये चारो strategies potentially applicable है डिस्ट्रिब्यूटेड सिस्टम के लिए | ऑस्ट्रिच अल्गोरिथम जितनी सिंगल प्रोसेसर सिस्टम के लिए पॉपुलर और अच्छी है उतनी ही वो डिस्ट्रिब्यूटेड सिस्टम के लिए पॉपुलर और अच्छी है | डिस्ट्रिब्यूटेड सिस्टम में प्रोग्रामिंग, ऑफिस ऑटोमेशन, प्रोसेस कंट्रोल और कई सारी एप्लीकेशन में इसका यूज होता है|

Deadlock detection और रिकवरी भी काफी पॉपुलर है | क्योकि prevention अथवा avoidance काफी कठिन पड़ जाते है | deadlock prevention भी पॉसिबल है पर यह सिंगल प्रोसेसर सिस्टम की तुलना में डिस्ट्रिब्यूटेड सस्टम में ज्यादा कठिन होता है | deadlock avoidance का डिस्ट्रिब्यूटेड सिस्टम मेम कभी यूज नहीं किया जाता, यहाँ तक कि इसे सिंगल प्रोसेसर सिस्टम में भी यूज नहीं किया जाता|

इस ब्लॉग को लेकर आपके मन में कोई भी प्रश्न है तो आप हमें इस पते पर ईमेल लिख सकते है|

आशा करता हूँ, कि आपने इस पोस्ट ‘deadlock in distributed operating system in hindi‘ को खूब एन्जॉय किया होगा|

आप स्वतंत्रता पूर्वक अपना बहुमूल्य फीडबैक और कमेंट यहाँ पर दे सकते है|

आपका समय शुभ हो|