All mock tests are FREE till 31 December — register to save your progress

A system has 12 instances of a resource R shared among four processes. The maximum need and current allocation of each process are:
ProcessMax NeedCurrent Allocation
P183
P294
P352
P431
With reference to the current allocation, is the system in a safe state? If so, what is a safe sequence?

Pick an option to check yourself, or open the answer below.

Show answer & explanation

Correct answer: C. Yes, P4 P3 P1 P2

Explanation

Total allocated = 3+4+2+1 = 10, so Available = 12 − 10 = 2. Each process's remaining Need = Max − Allocation: P1 needs 5, P2 needs 5, P3 needs 3, P4 needs 2. Only P4's need (2) can be met with Available=2, so run P4 to completion first; it releases its 1 allocated unit, raising Available to 3, which now covers P3's need (3) — run P3, releasing 2 more, raising Available to 5, which covers P1's need (5) — run P1, releasing 3 more, raising Available to 8, which comfortably covers P2's need (5). Every process finishes, so the system is safe with sequence P4, P3, P1, P2, option (iii).

More Computer System Architecture questions