Suppose a system has 12 magnetic tape drives and at time \(𝑡_0\), three…
2019
Suppose a system has 12 magnetic tape drives and at time \(𝑡_0\), three processes are allotted tape drives out of their need as given below:
\(\begin{array}{ccc} & \text{Maximum Needs} & \text{Current Needs} \\ p_0 & 10 & 5 \\ p_1 & 4 & 2 \\ p_2 & 9 & 2 \end{array}\)
At time \(𝑡_0\), the system is in safe state. Which of the following is safe sequence so that deadlock is avoided?
- A.
\(⟨𝑝_0,𝑝_1,𝑝_2⟩ \) - B.
\(⟨𝑝_1,𝑝_0,𝑝_2⟩ \) - C.
\(⟨𝑝_2,𝑝_1,𝑝_0⟩ \) - D.
\(⟨𝑝_0,𝑝_2,𝑝_1⟩\)
Attempted by 112 students.
Show answer & explanation
Correct answer: B
Initial calculations: compute allocations, availability, and remaining needs.
Allocated: p0 = 5, p1 = 2, p2 = 2 (total allocated = 9).
Available = 12 − 9 = 3.
Remaining needs (maximum − allocated): p0 needs 5, p1 needs 2, p2 needs 7.
Safety check (step-by-step):
Step 1: p1 requires 2 and available = 3, so p1 can finish. After p1 finishes, available = 3 + allocation of p1 (2) = 5.
Step 2: p0 requires 5 and available = 5, so p0 can finish. After p0 finishes, available = 5 + allocation of p0 (5) = 10.
Step 3: p2 requires 7 and available = 10, so p2 can finish. After p2 finishes, available = 10 + allocation of p2 (2) = 12.
Conclusion: A safe sequence that avoids deadlock is ⟨p1, p0, p2⟩.
A video solution is available for this question — log in and enroll to watch it.