edited by
3,836 views
2 votes
2 votes
A system is  having 3 user process , each requiring 2 units of resource R  . WHAT IS  the minimum and maximum no. of units of   R  required such that no deadlock will occur ?
edited by

3 Answers

Best answer
8 votes
8 votes

if we provide $3$ instances of $R$ then there is a possibility that following situation happens:

Where each process is allocated one instance and each process is waiting for one more instance of $R$. So definitely with $3$ instance deadlock may occur.

So we need to provide $1$ more instance of $R$ and then one of the processes can complete and release two instances of $R$ and subsequently other two processes can also finish their execution.

Therefore minimum $4$ instances of $R$ required.

selected by
2 votes
2 votes

Condition for deadlock is 
process * ( max need -1) = RESOURCES.  ..(i)

here process = 3 

each process requiring 2 units of resource R  so maximum need is 2

so according to (i)   3(2-1) = x ,  here x = maximum number of resources

3 = x

x =  3

so at max 3 resources require  to be in deadlock .

maximum resources require are 3 to be in deadlock so if we have (3+1 =4)  resources then there is no deadlock.

hence maximum value is also 4 .

edited by
1 votes
1 votes
Question seems to be arbitrary. It should be maximum resources when we can have deadlock and minimum number of resources to not have deadlock.

Each process requiring 2 units of resource R  so maximum need is 2

so according to formula   3(2-1) = x ,  here x = maximum number of resources

x =  3

so at max 3 resources will be required to be in deadlock .

As maximum no of resources required is 3 to be in deadlock so if we have one more resource, (3+1 =4)  resources then there is NO deadlock.
Why?

Because in that case if all process have 1 resource and require 1 to complete. We have one free resource which we can allocate to any process, after which it will complete execution and release resources. Other process can now use released resources to complete.

Hence maximum value is also 4 for NO deadlock condition. .
edited by
Answer:

Related questions

0 votes
0 votes
0 answers
1
Raj Singh 1 asked Jan 1, 2019
1,384 views
Many problems on gateoverflow asks whether the given code satisfies progress requirement of the solution for the critical section problem. Most of these code contain mult...