Suppose n processes, P1, …. Pn share m identical resource

Suppose n processes, P1, …. Pn share m identical resource units, which can be reserved and released one at a time. The maximum resource requirement of process Pi is Si, where Si > 0. Which one of the following is a sufficient condition for ensuring that deadlock does not occur?

Vivek Vikram Singh vivek14 14 Oct 2014 08:12 pm

There are N processes and they share M resources.

Sum of the requirement of all processes will be " Sum of all Si" ie \(\sum\limits_{i=1}^n S_i\) . Now If you dont want the deadlock to occur,then you should share M resources such that each process will get 1 less than their maximum requirement and then add 1 resource to any one of the processes. This way you can avoid deadlock.

​ ​So the expression should be like this : \(\sum\limits_{i=1}^n S_i\)- N+ 1= M meaning we are summing all requirements, then subtracting N,that is 1 resource from each of the processes' requirement, so that all Processes will be waiting. then adding 1, that is allocating 1 resource to any 1 of the processes so that it can complete its execution and leave its resources so that other process can use. This should be equal to M.

Now if you move N to RHS then expression will be like \(\sum\limits_{i=1}^n S_i\)-1 = M+N.

If clearly, now if we ignore 1, then the expression wil be reduced to \(\sum\limits_{i=1}^n S_i\) < M+N. Right.

I hope I made my point and doubts are clear.


Shreyans Dhankhar shreyans 17 Oct 2014 01:13 pm

every process Pi require Si units 
so in worst case we can give Si-1 to a process Pi
so total we have n processes and m resources 
so every process we r giving Si-1 i.e (S1-1)+(S2-1)+.....+(Sn-1)<m (in order to avoid deadlock)
(S1+S2+........+Sn)-(1+1+......+n times)<m
sigma S1-n<m
sigma Si<m+n

GateMaster Prime gatemasterpr 5 Mar 2015 06:24 pm

What's wrong with option D)..? It seems true to me.