Consider a system with ten units of resource R and three processes: X, Y, and…
2018
Consider a system with ten units of resource R and three processes: X, Y, and Z. The maximum resource requirement and current allocation to these processes are as follows:
X | Y | Z | |
Maximum Resource Requirement | 8 | 7 | 5 |
Current Allocation | 4 | 1 | 3 |
Now, consider the following resource requests:
(i) X makes a request for 2 resource units
(ii) Y makes a request for 2 resource units
(iii) Z makes a request for 2 resource units
For the system to be in safe state, which of the following must be granted?
- A.
Only request (i) must be granted
- B.
Only requests (i) and (ii) must be granted
- C.
Only request (iii) must be granted
- D.
Only request (ii) must be granted
Attempted by 102 students.
Show answer & explanation
Correct answer: C
Concept: The Banker's Algorithm keeps a system in a safe state by checking, before granting any request, whether every process's remaining need can eventually be met in some order once processes finish and release resources. Having enough available units for the immediate request is not enough by itself; the requesting process's own leftover need after the grant, and every other process's need, must still be satisfiable in sequence.
Applying it here:
Compute total available units: 10 total minus (4 + 1 + 3) = 8 allocated, giving 2 units available.
Compute the remaining need of each process as Max minus Allocation: X needs 8 − 4 = 4 units, Y needs 7 − 1 = 6 units, Z needs 5 − 3 = 2 units.
Test request (i): X asks for 2 units, within its need (4) and the available pool (2), so it can be handed out. But after granting it, available drops to 0 and X's own remaining need is still 2 units, which nothing can supply, so no process can finish and the state becomes unsafe.
Test request (ii): Y asks for 2 units, also within its need (6) and the available pool (2). After granting it, available again drops to 0, and Y's own remaining need is still 4 units, so again nothing can finish, and the state becomes unsafe.
Test request (iii): Z asks for 2 units, which exactly matches Z's remaining need. After granting it, Z's remaining need becomes 0, so Z finishes immediately and releases its full allocation of 5 units back to the pool. That refill of 5 lets X finish next (X's need of 4 is now covered), and X's release then lets Y finish (Y's need of 6 is now covered) — a complete safe sequence Z, X, Y exists.
Cross-check: Requests (i) and (ii) together would need 4 units at once, more than the 2 units actually available, so they could not even be granted simultaneously — reinforcing that only isolating request (iii) keeps the system safe. Tracking the total also confirms nothing is lost: after Z, X, and Y finish in turn, the full 10 units (5 + 4 + 1) are back with the system.
Hence, for the system to remain in a safe state, only request (iii) must be granted.