What values of N could lead to a deadlock?

a system has 6 identical resources and N processes competing for them .each process can request at most 2 resources.which one of the following values of N could lead to a deadlock? a)1 b)2 c)3 d)4 

2Comments
shivani @shivani1234
20 May 2017 01:58 pm
  • here, none of the options is correct
  • assuming all process need 2 resources(max value), then for deadlock to not occur;
  • N+1 resources is needed  , and N+1<=6, so N=5
  • that means 5 process can compete for max(2 resources) without deadlock.
abhinandan @abhinandan
21 May 2017 03:35 am

all the given options given are wrong.

for solving such type of questions allocate 1 less than the max resources need to each process.

say if a process needs 3 resources then allocate it 2 resources.

now in this question, the process needs 2 instances to complete its execution.

so let's allocate 1 less than the required to various process and then verify how many processes can be present in max. p1 (1 instance), p2(1 instance) ,p3( 1 instance), p4(1 instance) p5(1 instance ) p6(1 instance).

if we have the above distribution of instance of resources then the system will be in deadlock.

so instead of allocating the last instance to p6 process allocate it to p5 process and see whether the system is in deadlock or not

p1 (1 instance), p2(1 instance),p3( 1 instance), p4(1 instance) p5(2 instance )

since a process needs max of 2 instances of resources so here p5 can complete its execution and free up its 2 instances of resources which it was holding. now, these released 2 resources can be allocated to any of the remaining processes. and we can see the system is deadlock-free.

so the answer is max 5 processes can be present in the system so that there is no deadlock.