Skip to content
Related Articles

Related Articles

GATE | GATE CS 2021 | Set 2 | Question 53

View Discussion
Improve Article
Save Article
Like Article
  • Last Updated : 23 May, 2021

Consider a computer system with multiple shared resource types, with one instance per resource type. Each instance can be owned by only one process at a time. Owning and freeing of resources are done by holding a global lock (L). The following scheme is used to own a resource instance:

function OWNRESOURCE(Resource R)
    Acquire lock L // a global lock
    if R is available then
        Acquire R
        Release lock L
        if R is owned by another process P then 
        Terminate P, after releasing all resources owned by P  
        Acquire R  
        Restart P
        Release lock L
        end if
    end if    
end function 

Which of the following choice(s) about the above scheme is/are correct?
(A) The scheme ensures that deadlocks will not occur
(B) The scheme may lead to live-lock
(C) The scheme may lead to starvation
(D) The scheme violates the mutual exclusion property

Answer: (A) (B) (C)

Explanation: (A) The scheme ensures deadlock free operation, as there is no hold-and-wait condition possible.

(B) The scheme may lead to priority inversion problems, and hence live-lock is possible.

(C) The scheme may lead to starvation. For example, the priority process can get scheduled repeatedly and keeps on killing the lower priority processes. Hence, a low priority process may starve.

(D) Mutual exclusion is satisfied as only one process can acquire and release locks at a time.

Quiz of this Question

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!