Open In App
Related Articles

GATE | GATE-CS-2007 | Question 57

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report
A single processor system has three resource types X, Y and Z, which are shared by three processes. There are 5 units of each resource type. Consider the following scenario, where the column alloc denotes the number of units of each resource type allocated to each process, and the column request denotes the number of units of each resource type requested by a process in order to complete execution. Which of these processes will finish LAST?
 
    alloc           request
    X Y Z            X Y Z
P0  1 2 1            1 0 3
P1  2 0 1            0 1 2
P2  2 2 1            1 2 0 
(A) P0 (B) P! (C) P2 (D) None of the above, since the system is in a deadlock

Answer: (C)

Explanation: A single processor system has three resource types X, Y and Z, which are shared by three processes. There are 5 units of each resource type. So, the resource instances which are left being unallocated = { unallocated resources= total resources-allocated resources } now, from the request table, you can say that only request of P1 can be satisfied. So P1 can finish its execution first. Once P1 is done, it releases 2, 0 and 1 units of X, Y and Z respectively which were allocated to P1.So, Now unallocated resource instance are = + = Now Among P0 and P2, needs of P0 can only be satisfied. So P0 finishes its execution. Once P2 is done, It releases 2,2,and 1 units of X,Y and Z respectively which were allocated to P2.SO, Now unallocated resource instance are= + = . Finally, P2 finishes its execution. So, P2 is the process which finishes in end. Option (C) is the correct answer. See question 2 of https://www.geeksforgeeks.org/operating-systems-set-13/ Reference: https://www.geeksforgeeks.org/bankers-algorithm-in-operating-system-2/ This solution is contributed by Nitika Bansal

Quiz of this Question

Last Updated : 28 Jun, 2021
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads