in Operating System edited by
23,666 views
54 votes
54 votes

Which of the following is NOT true of deadlock prevention and deadlock avoidance schemes?

  1. In deadlock prevention, the request for resources is always granted if the resulting state is safe

  2. In deadlock avoidance, the request for resources is always granted if the resulting state is safe

  3. Deadlock avoidance is less restrictive than deadlock prevention

  4. Deadlock avoidance requires knowledge of resource requirements apriori..

in Operating System edited by
23.7k views

4 Comments

deadlock prevention we have to check all 4 necessary conditions., while in deadlock avoidance we need to check safe sequence

4
4
In deadlock prevention, we need to disable at least one condition among four necessary conditions of deadlock.

Four deadlock conditions with "way to disable them" are explained below:-

1. Mutual Exclusion :- To disable this, shared resources are used (means one resource can be shared with many processes simultaneously).

2. Hold and wait :- To disable this, system can make a rule that every process should occupy needed resources in starting of their execution. If process request for any resource later than that process should release all previously allocated resources.

3. No preemption :- To disable this, preemption is allowed.

4. Circular wait :- To disable this, system provide number to all resources and make a rule that processes can request for higher numbered resources than max. number of their currently occupied resources.
6
6

In deadlock prevention we don’t check all four necessary conditions for deadlock. Making sure that at least one of them does not occur is sufficient.

Furthermore, each resource type can have their own deadlock handling approach (prevention, avoidance, recovery or ignorance)

Galvin 10th edition section – 8.4 

 

0
0

The deadlock-avoidance algorithm dynamically examines the resource-allocation state to ensure that there can never be a circular-wait condition.

Under the hood, deadlock avoidance is making sure that circular wait never occurs.

reference

0
0

4 Answers

85 votes
85 votes
Best answer

(A).  In deadlock prevention, we just need to ensure one of the four necessary conditions of deadlock doesn't occur. So, it may be the case that a resource request might be rejected even if the resulting state is safe. (One example, is when we impose a strict ordering for the processes to request resources). 

Deadlock avoidance is less restrictive than deadlock prevention. Deadlock avoidance is like a police man and deadlock prevention is like a traffic light. The former is less restrictive and allows more concurrency. 

Reference: http://www.cs.jhu.edu/~yairamir/cs418/os4/tsld010.htm

edited by
by

4 Comments

edited by

A)False

B) Banker algorithm . Here we have to know resulting state is safe or not.

C) yes, in deadlock prevention we have to check all 4 necessary conditions., while in deadlock avoidance we need to check safe sequence . Say u want to go to college by bike. But u have no license. So, to avoid traffic police, u choose other road and not to go with main road. That is deadlock avoidance .

Deadlock prevention u made license and then go by main road only.

D)Knowledge of resource requirement nothing but Banker algo. Where we need to know max available resource, no of resource needed etc.

"aprori" here means it is a theoretical observation  link

41
41
Example of policeman and traffic light is awesome. I understand whole concept with this example.
7
7
Sir,you mean police man is less restrictive than traffic light:p
6
6
Yes. Suppose if in one road no vehicles are there, policeman will allow vehicles from other roads but not a traffic light. But let's wait for traffic lights being made with AI by the CS geeks here :)
52
52
68 votes
68 votes

Option A is answer.
The main difference between deadlock prevention and deadlock avoidance lies in the definition of deadlock itself.
We know Necessary_conditions for deadlock to happen. Means deadlock can be there only if these conditions are satisfied. But it does not mean that if these conditions are satisfied then deadlock will always be there.

The above definition is the main idea and fine line on that both strategies differ.

Deadlock Prevention says: Let's prevents one of the conditions.
Deadlock Avoidance says: Let me allow all conditions to hold simultaneously (all conditions holds simultaneously doesn't guarantee deadlock) but I will also check any chance of deadlock (i.e system in the safe state if I allocate requested resource.), It allows the four conditions but makes judicious decisions so that the deadlock point is not potentially reached.

Clearly, Deadlock prevention is more restrictive. It decreases throughput also. At the same time we can not use Deadlock avoidance practically as it demands to know uses of all resources in advance.

The analogy is like this:
(Now take an example of protection from viral through the water.)
Deadlock Prevention: Don't use water
Deadlock Avoidance: Use water but first filter out.

4 Comments

Nice explanation
0
0

@rohan30 circular wait is not satisfied here, for circular wait to be satisfied P1 has to wait for P2 and P2 has to wait for P1. P1 is not waiting for anyone here. P1 needs one instance of resource type R2 which is already available, why would it wait for P2?

0
0

@Sachin Mittal 1 sir plz tell srestha mam’s doubt i also want to know this?

0
0
4 votes
4 votes

Deadlock prevention scheme handles deadlock by making sure that one of the four necessary conditions don't occur. In deadlock prevention, the request for a resource may not be granted even if the resulting state is safe. (See the Galvin book slides for more details)

3 votes
3 votes
option A. In order to prevent deadlock we number the resources and resources are granted to process only in increasing fashion ( to avoid circular wait) so even if the resulting re resource request results in safe sequence and it is not in increasing order then that request will be rejected.

option B. yes, the banker algorithm states that.

option C. same explanation as option A

option D. yes we should know in advance the max instances of each resource a process will be requiring.
Answer:

Related questions