The Gateway to Computer Science Excellence
+35 votes
7.7k views

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 by
edited by | 7.7k views
+2

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

0
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.

4 Answers

+60 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

by
edited by
+27

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

+2
Example of policeman and traffic light is awesome. I understand whole concept with this example.
+3
Sir,you mean police man is less restrictive than traffic light:p
+24
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 :)
+48 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.

by
+1
indeed a nice answer.
+2

" 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."

Can u give me example "4 condition satisfied and deadlock not satisfied" ?

+12
In one word ,

In case of deadlock prevention we have to check all 4 necessary conditions... while in deadlock avoidance we just need to check system is in safe state or not !

so less task for avoidance hence less strict that prevention :)
+2

Here deadlock is not there even though all four conditions are satisfied

+1

@Sachin Mittal 1

nice explanation.

(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.

This clears every thing.

0
Nice explanation
+3 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)

by
0 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.
by
Answer:

Related questions

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
52,345 questions
60,468 answers
201,792 comments
95,271 users