2.6k views
A system contains three programs and each requires three tape units for its operation. The minimum number of tape units which the system must have such that deadlocks never arise is _________.
edited | 2.6k views
+1

Pigeonhole Principle :)

Up to, $6$ resources, there can be a case that all process have $2$ each and dead lock can occur. With $7$ resources, at least one process's need is satisfied and hence it must go ahead and finish and release all $3$ resources it held. So, no dead lock is possible.
selected by
0
What if we think this manner, let the number of resources be 3 i.e. 3 tape units are given. These can be allocated to any one process, which after execution will free those 3 tape units. Now these 3 can be given to the other waiting process which will free it after sometime and lastly, give it to 3rd waiting process. The only disadvantage of this is the processes may suffer from starvation. But can't minimum number of resources be 3?
For these type of problems in which every process is making same number of requests, use the formula

$$n.(m-1)+1\leq r$$
where,
$n= \text{ no. of processes}$
$m=\text{resource requests made by processes}$
$r=\text{no. of resources}$

So, in above problem we get $3.(3-1)+1\leq r \implies r \geq 7$

Minimum number of resource required to avoid deadlock is $7.$

Max number of resourses by which deadlock happen

P1=2

P2=2

P3=2

therefore minimum number of resourses by which deadlock not happen=6+1>=7

If 6 resources are there then it may be possible that all three process have 2 resources and waiting for 1 more resource. Therefore, all of them will have to wait indefinitely. If 7 resources are there, then atleast one must have 3 resources so deadlock can never occur.