You do not have permission to edit this page, for the following reason:

The action you have requested is limited to users in one of the groups: Users, Administrators.


You can view and copy the source of this page.

Return to GATE2010 q46.

A system has <math>n</math> resources <math>R_0 ,..., R_n-1</math> , and <math>k</math> processes <math>P_0 ,.....P_{k-1}</math> . The implementation of the resource request logic of each process <math>P_i</math> . is as follows:

if (<math>i% 2==0</math>) {
  if (<math>i<n</math>) request <math>R_i</math> ;
  if (<math>i+2<n</math>)request <math>R_{i+2}</math> ;
}
else {
  if (<math>i<n</math>) request <math>R_{n-i}</math> ;
  if (<math>i+2<n</math>) request <math>R_{n-i-2}</math> ;
}


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

Solution[edit]

From the resource allocation logic, it's clear that even numbered processes are taking even numbered resources and all even numbered processes take 2 resources. Now, if we make sure that all odd numbered processes take odd numbered resources, then deadlock cannot occur. The "else" case of the resource allocation logic, is trying to do that. But, if n is odd, <math>R_{n-i}</math> and <math>R_{n-i-2}</math> will be even and there is possibility of deadlock. So, only <math>B</math> and <math>D</math> are the possible answers.

Now, in <math>D</math>, we can see that <math>P_0</math> requests <math>R_0</math> and <math>R_2</math>, <math>P_2</math> requests <math>R_2</math> and <math>R_4</math> and so on until, <math>P_{18}</math> requests <math>R_{18}</math> and <math>R_{20}</math>. At the same time <math>P_1</math> requests <math>R_{40}</math> and <math>R_{38}</math>, so on until <math>P_{19}</math> requests <math>R_{22}</math> and <math>R_{20}</math>. i.e.; there are no two processes requesting the same two resources and hence there can't be a cycle of dependencies and hence no deadlock is possible.

But for <math>B</math>, <math>P_8</math> requests <math>R_8</math> and <math>R_{10}</math> and <math>P_{11}</math> also requests <math>R_{10}</math> and <math>R_8</math>. Hence, a deadlock is possible.





blog comments powered by Disqus