First time here? Checkout the FAQ!
+1 vote
Q 1)  The query which is coming in my mind is which of the below techniques requires apriori information regarding the potential use , request of resources ?

a) Deadlock prevention

b) Deadlock avoidance

c) Deadlock detection

Q 2) Also what is the order of restrictiveness of the above techniques regarding the allocation of resources ?

Q 3) Is deadlock detection technique meant for before the deadlock has occured or after the deadlock has occured ?
asked in Operating System by Veteran (87k points) 15 57 292 | 148 views

1 Answer

+2 votes
Best answer

Deadlock Prevention: The goal is to ensure that at least one of the 4 necessary conditions for deadlock never hold. The system does not require additional apriori information regarding the overall potential use of each resource for each process. This is difficult to implement in practice.

Deadlock Avoidance: The goal is to plan very carefully so that the system will not enter an unsafe state. In order for the system to decide whether the next state will be safe or unsafe, it must know in advance, at any time the additional apriori information regarding the overall potential use of each resource for each process.

Deadlock Detection: The goal is to find a deadlock before or after it has happened. Detecting the possibility of a deadlock before it occurs is more difficult. The system does not requires additional apriori information regarding the overall potential use of each resource for each process in all cases.

Therefore, the answer to your first question is (b) Deadlock Avoidance.

Answer to the second question: For deadlock detection, the resource allocation strategy is very liberal. That means, resources are granted as and when requested. For deadlock prevention, the resource allocation is very strict or   rather conservative. It generally under utilizes the resources. The resource allocation strategy for deadlock avoidance is not that liberal, it checks whether a safe sequence exists before allocating (very similar to the process of a banker checking its financial position before passing a loan). At the same time, it is not that conservative as in deadlock prevention.

Answer to the third question is that Deadlock Detection can be used to detect a deadlock before or after it has happened.

I think this explanation clarifies all three questions.

answered by Loyal (4.4k points) 5 15
selected by
Thanks a lot @visakh r..
How Deadlock detection can be used to detect a deadlock before it has happened ?

@visakh ,

Deadlock Detection can be used to detect a deadlock before or after it has happened.

Is it ?

I think In this technique, system does not prevent to attempt deadlocks from occuring .Instead it lets them occur , tries to detect when this happens and then takes some action to recover after the fact .

What action it takes to detect a deadlock ? Its wait for graph

Deadlock can be detected by examining which processes are waiting for which resources. For example, two processes A and B may attempt to acquire the following locks before executing a critical section:

Thread A: x, y, z

Thread B: z, a, b, c, x

Deadlock is possible if A tries to acquire lock z after B has already acquired z. Process A will continue to try to acquire z, holding on to x and y. Eventually, B will try to acquire x and deadlock is reached. Each process tries to acquire a lock held by another process.

When only one instance of each resource type is available, a variant of resource allocation graph called wait-for-graph is used to represent the processes. Deadlock detection algorithms work by creating a finite state model that has a set of states and  transitions. All the paths in the WFG are periodically run through the finite state model and checked for cycle forming possibility. If there is a chance for cycle in WFG, then deadlock is almost imminent.

For more details regarding finite model based deadlock detection, please go throuh this paper:

Even I think same

Under the deadlock detection, deadlocks are allowed to occur. Then the state of the system is examined to detect that a deadlock has occurred and subsequently it is corrected and recovered
yes deadlock prevention says just break all conditions so that deadlock cant even think of happening...deadlock avoidance says we should take all safety measures to ensure deadlock shouldnt happen like safe state concept...and deadlock detection is deadlock detection and "recovery" means let deadlock happen if it wants so we will see what to do then like peempt the resources,rollback,kill the process etc....and  detection also provides waits for graph as mentioned  above to detect it before happening also..

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
Top Users Oct 2017
  1. Arjun

    23210 Points

  2. Bikram

    17018 Points

  3. Habibkhan

    6652 Points

  4. srestha

    5864 Points

  5. Debashish Deka

    5430 Points

  6. jothee

    4908 Points

  7. Sachin Mittal 1

    4762 Points

  8. joshi_nitish

    4274 Points

  9. sushmita

    3954 Points

  10. Silpa

    3698 Points

Recent Badges

Regular Juhi Sehgal
Popular Question vineet.ildm
Nice Comment Arjun
100 Club vipul verma
Notable Question jothee
Popular Question jothee
Nice Question shivangi5
Regular rinks5
Notable Question shipra tressa
Regular sasi
27,247 questions
35,056 answers
33,183 users