Consider a system with 6 processes, where each process needs 2 copies of Resource R. The maximum units of R required to cause deadlock is ??

• What have you tried so far to answer this question yourself? Where did you get stuck? – ttnick Sep 18 at 14:23

For a system to be in deadlock it must not be able to proceed. A process may be not started, complete, waiting for a resource, processing a resource, or be deadlocked.

It's normal for a process to have to wait for a resource, so deadlock only arises if it is shown that the resource can never be made available. For the information given, and absent the specification any of the other conditions, then I think the answer must be 1.

Perhaps the question needs to be more explicit with respect to its constraints.

I am assuming you know the $$4$$ conditions required for the system to be in deadlock.

Now let's consider there are $$n$$ processes in the system $$P_1, P_2, P_3, …… , P_n$$ where

Process $$P_1$$ requires $$x_1$$ units of resourc $$R$$

Process $$P_2$$ requires $$x_2$$ units of resource $$R$$

Process $$P_3$$ requires $$x_3$$ units of resource $$R$$

.....

Process $$P_n$$ requires $$x_n$$ units of resource $$R$$

So for deadlock to exist, in worst case,the number of units that each process holds = One less than its maximum requirement.So we can say that for system in deadlock,

Process $$P_1$$ holds $$x_1 -1$$ units of resource $$R$$

Process $$P_2$$ holds $$x_2 -1$$ units of resource $$R$$

Process $$P_3$$ holds $$x_3 -1$$ units of resource $$R$$

.....

Process $$P_n$$ holds $$x_n -1$$ units of resource $$R$$

Now, to break the deadlock,we just need one more unit of resource $$R$$ in the system. This is because that unit would be allocated to one of the processes and it would get execute and then release the resources held by it which can be used by other processes.

From here, we can say

Maximum number of units of resource $$R$$ that ensures deadlock

$$= (x_1-1) + (x_2-1) + (x_3-1) + …. + (x_n-1)$$

$$= ( x_1 + x_2 + x_3 + …. + x_n ) – n$$

$$= \sum_{x=1}^nx_i\ – n$$

Now in your question, $$n=6$$ and $$x_i = 2$$. Putting in the values of $$x_i$$ and $$n$$

$$= 2+2+2+2+2+2 - 6$$

$$=6$$

So the maximum units of $$R$$ required to cause deadlock is $$6$$