Consider a system with twelve magnetic tape drives and three processes 𝑃1,𝑃2…
2015
Consider a system with twelve magnetic tape drives and three processes 𝑃1,𝑃2 and 𝑃3. process 𝑃1 requires maximum ten tape drives, process 𝑃2 may need as many as four tape drives and 𝑃3 may need upto nine tape drives. Suppose that at time 𝑡1, process 𝑃1 is holding five tape drives, process 𝑃2 is holding two tape drives and process 𝑃3 is holding three tape drives, At time 𝑡1, system is in:
- A.
safe state
- B.
unsafe state
- C.
deadlocked state
- D.
starvation state
Attempted by 89 students.
Show answer & explanation
Correct answer: B
Compute available resources and remaining needs.
Total tape drives = 12. Allocated: P1 = 5, P2 = 2, P3 = 3. Available = 12 - (5 + 2 + 3) = 2.
Remaining need for P1 = maximum 10 - allocated 5 = 5
Remaining need for P2 = maximum 4 - allocated 2 = 2
Remaining need for P3 = maximum 9 - allocated 3 = 6
Apply the Banker's safety check:
With 2 available, the process that needs 2 can finish (P2). After it finishes it releases its 2 allocated drives, so available becomes 4.
Now available = 4, but the other processes need 5 and 6 respectively. Neither can finish with 4 available, so no sequence allows all processes to finish.
Therefore the system is in an unsafe state.
Note: Unsafe means there is no guaranteed safe sequence for all processes; it is not the same as deadlock. This situation is not deadlocked because at least one process can finish immediately, but the system is still unsafe.
A video solution is available for this question — log in and enroll to watch it.