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 82 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.