🔒

Exam Module Subscription Required

You need an active Exam Module Subscription to access this content. Subscribe now to unlock the exam materials and continue your preparation.

Banker's Algorithm — Step-by-Step Solution
Total System Resources: R1 = 10, R2 = 5, R3 = 7
Step 1: Calculate Current Resource Need
Current Resource Need = Max Need - Allocated Resource
  • P0: (7, 5, 3) - (0, 1, 0) = (7, 4, 3)
  • P1: (3, 2, 2) - (2, 0, 0) = (1, 2, 2)
  • P2: (9, 0, 2) - (3, 0, 2) = (6, 0, 0)
  • P3: (2, 2, 2) - (2, 1, 1) = (0, 1, 1)
  • P4: (4, 3, 3) - (0, 0, 2) = (4, 3, 1)
Step 2: Calculate Initial Available Resource

First, sum up all currently allocated resources across processes:

  • Total Allocated R1 = 0 + 2 + 3 + 2 + 0 = 7
  • Total Allocated R2 = 1 + 0 + 0 + 1 + 0 = 2
  • Total Allocated R3 = 0 + 0 + 2 + 1 + 2 = 5
Available = Total System Resources - Total Allocated Resources
Available = (10, 5, 7) - (7, 2, 5) = (3, 3, 2)
Complete Snapshot Table Step 3: Execution Trace (Safety Algorithm)
1. Execute Process P1:

Check if Need(P1) ≤ Available → (1, 2, 2) ≤ (3, 3, 2) — True

New Available = Available + Allocated(P1) = (3, 3, 2) + (2, 0, 0) = (5, 3, 2)

2. Execute Process P3:

Check if Need(P3) ≤ Available → (0, 1, 1) ≤ (5, 3, 2) — True

New Available = Available + Allocated(P3) = (5, 3, 2) + (2, 1, 1) = (7, 4, 3)

3. Execute Process P4:

Check if Need(P4) ≤ Available → (4, 3, 1) ≤ (7, 4, 3) — True

New Available = Available + Allocated(P4) = (7, 4, 3) + (0, 0, 2) = (7, 4, 5)

4. Execute Process P2:

Check if Need(P2) ≤ Available → (6, 0, 0) ≤ (7, 4, 5) — True

New Available = Available + Allocated(P2) = (7, 4, 5) + (3, 0, 2) = (10, 4, 7)

5. Execute Process P0:

Check if Need(P0) ≤ Available → (7, 4, 3) ≤ (10, 4, 7) — True

New Available = Available + Allocated(P0) = (10, 4, 7) + (0, 1, 0) = (10, 5, 7)

System Status: SAFE STATE
Safe Sequence: < P1, P3, P4, P2, P0 >
Topic Wise Question Bank
All Topics

1 thought on “M3: Operating System (Deadlock in Operating System)”

Leave a Comment

WhatsApp Telegram Messenger