Question

A system shares 9 tape drives. The current allocation and maximum requirement of tape drives for three processes are shown below:

Process Current Allocation Maximum Requirement
P1 3 8
P2 1 6
P3 3 5

Which of the following best describes current state of the system?

Choose one option
Official answer and solution
Official answer
B
From
Official GATE 2017 answer key

Solution

Run Banker's safety algorithm to determine whether the system is in a safe state and check for deadlock.

Calculate currently allocated resources and available resources:

  • Total tape drives =9= 9.
  • Current allocation: P1=3,P2=1,P3=3P_1 = 3, P_2 = 1, P_3 = 3.
  • Total allocated =3+1+3=7= 3 + 1 + 3 = 7.
  • Available drives =9−7=2= 9 - 7 = 2.

Calculate the Need vector for each process (Need=Max−Allocation\text{Need} = \text{Max} - \text{Allocation}):

  • Need(P1)=8−3=5\text{Need}(P_1) = 8 - 3 = 5
  • Need(P2)=6−1=5\text{Need}(P_2) = 6 - 1 = 5
  • Need(P3)=5−3=2\text{Need}(P_3) = 5 - 3 = 2

Run the safety algorithm with Available=2\text{Available} = 2:

  1. Check P3P_3: Need(P3)=2≤2\text{Need}(P_3) = 2 \le 2. P3P_3 can finish and release its allocated 3 tape drives.
    New available =2+3=5= 2 + 3 = 5.
  2. Check P1P_1: Need(P1)=5≤5\text{Need}(P_1) = 5 \le 5. P1P_1 can finish and release its allocated 3 tape drives.
    New available =5+3=8= 5 + 3 = 8.
  3. Check P2P_2: Need(P2)=5≤8\text{Need}(P_2) = 5 \le 8. P2P_2 can finish and release its allocated 1 tape drive.
    New available =8+1=9= 8 + 1 = 9.

A valid safe sequence ⟨P3,P1,P2⟩\langle P_3, P_1, P_2 \rangle exists. Therefore, the system is in a Safe state. A safe state is by definition Not Deadlocked.
This matches option B.

Final answer

B

Common trap

Assuming that having only 2 available drives while P1 and P2 need 5 means the system is unsafe; P3 can complete first and free up sufficient drives.

The answer is the one in the official GATE answer key. The solution is this site's own explanation.

Source

Paper
GATE 2017 Computer Science and Information Technology (CS) Session 2
Question
33 of 65, printed as CS Q.33
Section
Computer Science and Information Technology

Report an error in this question

GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.