An operating system has 13 tape drives. There are three processes P1, P2 & P3.…
2014
An operating system has 13 tape drives. There are three processes P1, P2 & P3. Maximum requirement of P1 is 11 tape drives, P2 is 5 tape drives and P3 is 8 tape drives. Currently, P1 is allocated 6 tape drives, P2 is allocated 3 tape drives and P3 is allocated 2 tape drives. Which of the following sequences represent a safe state ?
- A.
P2 P1 P3
- B.
P2 P3 P1
- C.
P1 P2 P3
- D.
P1 P3 P2
Attempted by 88 students.
Show answer & explanation
Correct answer: A
Key values: total drives = 13; allocations: P1 = 6, P2 = 3, P3 = 2; maximum needs: P1 = 11, P2 = 5, P3 = 8.
Available drives = 13 - (6 + 3 + 2) = 2
Remaining need for each process: P1 needs 11 - 6 = 5; P2 needs 5 - 3 = 2; P3 needs 8 - 2 = 6
Demonstration of a safe sequence: P2 → P1 → P3
Step 1: Start with available = 2. P2 needs 2, which can be satisfied. P2 finishes and releases its allocation of 3. New available = 2 + 3 = 5.
Step 2: With available = 5, P1 needs 5, which can be satisfied. P1 finishes and releases its allocation of 6. New available = 5 + 6 = 11.
Step 3: With available = 11, P3 needs 6, which can be satisfied. P3 finishes. All processes can complete in this order.
Conclusion: The system is in a safe state because the sequence P2, then P1, then P3 allows all processes to complete without deadlock.
A video solution is available for this question — log in and enroll to watch it.