Open In App
Related Articles

GATE | GATE CS 2010 | Question 65

Improve Article
Save Article
Like Article

A system has n resources R0,…,Rn-1,and k processes P0,….Pk-1.The implementation of the resource request logic of each process Pi is as follows: 

 if (i % 2 == 0) {
      if (i < n) request Ri
      if (i+2 < n) request Ri+2
else {
      if (i < n) request Rn-i
      if (i+2 < n) request Rn-i-2

In which one of the following situations is a deadlock possible?
(A) n=40, k=26
(B) n=21, k=12
(C) n=20, k=10
(D) n=41, k=19

Answer: (B)


Option B is answer

No. of resources, n = 21
No. of processes, k = 12

Processes {P0, P1....P11}  make the following Resource requests:
{R0, R20, R2, R18, R4, R16, R6, R14, R8, R12, R10, R10}

For example P0 will request R0 (0%2 is = 0 and 0< n=21). 

Similarly, P10 will request R10.

P11 will request R10 as n - i = 21 - 11 = 10.

As different processes are requesting the same resource, deadlock
may occur. 

Quiz of this Question

Last Updated : 28 Jun, 2021
Like Article
Save Article
Similar Reads