- 2073 Bhadra · 3+7 marks
Deadlock vs postponement; Banker's 4 resources
Short answer
Deadlock involves a cycle of waiting processes, while indefinite postponement (starvation) is a single process waiting long due to unfair scheduling. The system's total instances (6,4,4,2) give Available (1,1,2,0). Banker's algorithm yields the safe sequence P2, P0, P3, P4, P1. The state is safe.
What is the difference between deadlock and indefinite postponement? Consider a system with 5 concurrent processes (P0, P1, P2, P3, P4) and 4 resource types (R0, R1, R2, R3). The number of instances of each resource type in the system are 6, 4, 4, 2 respectively. Allocation table and Maximum claim table are as follows:
| Process | Allocation (R0 R1 R2 R3) | Maximum claim (R0 R1 R2 R3) |
|---|---|---|
| P0 | 2 0 1 1 | 3 2 1 1 |
| P1 | 1 1 0 0 | 1 2 0 2 |
| P2 | 1 1 0 0 | 1 1 2 0 |
| P3 | 1 0 1 0 | 3 2 1 0 |
| P4 | 0 1 0 1 | 2 1 0 1 |
| Is the state safe? If so, show the safe execution of the processes. |
Deadlock vs indefinite postponement
| Point | Deadlock | Indefinite postponement (starvation) |
|---|---|---|
| Meaning | Processes wait forever for each other's resources | A process waits for a long, unbounded time because others are always preferred |
| Cause | Four conditions hold together (circular wait etc.) | Unfair scheduling or resource allocation policy |
| Processes affected | All processes in the cycle | Usually one or a few low-priority processes |
| Other processes | Cannot proceed in the set | Others continue normally |
| Resolution | Needs prevention, avoidance or recovery | Aging, fair policy (FCFS queue) |
| Example | P holds printer, wants scanner; Q the reverse | Low priority job never gets CPU; SSTF disk request far away |
Banker's algorithm
Total = (6, 4, 4, 2). Sum of Allocation = (5, 3, 2, 2), so Available = (1, 1, 2, 0).
Need = Max − Allocation:
| Process | Allocation | Max | Need |
|---|---|---|---|
| P0 | 2 0 1 1 | 3 2 1 1 | 1 2 0 0 |
| P1 | 1 1 0 0 | 1 2 0 2 | 0 1 0 2 |
| P2 | 1 1 0 0 | 1 1 2 0 | 0 0 2 0 |
| P3 | 1 0 1 0 | 3 2 1 0 | 2 2 0 0 |
| P4 | 0 1 0 1 | 2 1 0 1 | 2 0 0 0 |
Work = (1, 1, 2, 0)
| Step | Process | Need | Need ≤ Work | Work after |
|---|---|---|---|---|
| 1 | P2 | 0 0 2 0 | yes | 1 1 2 0 + 1 1 0 0 = 2 2 2 0 |
| 2 | P0 | 1 2 0 0 | yes | 2 2 2 0 + 2 0 1 1 = 4 2 3 1 |
| 3 | P3 | 2 2 0 0 | yes | 4 2 3 1 + 1 0 1 0 = 5 2 4 1 |
| 4 | P4 | 2 0 0 0 | yes | 5 2 4 1 + 0 1 0 1 = 5 3 4 2 |
| 5 | P1 | 0 1 0 2 | yes | 5 3 4 2 + 1 1 0 0 = 6 4 4 2 |
All processes finish and Work equals the total (6, 4, 4, 2).
Answer: The state is SAFE. Safe sequence: P2 → P0 → P3 → P4 → P1.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Deadlock conditions; Banker's with 4 processes · Operating System, chapter 7
- Deadlock conditions; Banker's safe sequence · Operating System, chapter 7
- Deadlock, postponement, prevention, 2 processes · Operating System, chapter 7
- Banker's algorithm, 5 processes, 4 resources · Operating System, chapter 7
- Deadlock detection with allocation matrices · Operating System, chapter 7
- Show i1 = i2 = -V/(R1+R2+R3) at t=0+ · Electrical Circuit Theory, chapter 2
- Get data from P0, send to P1 (asm and C) · Embedded System, chapter 9
- Liang-Barsky: P1(-5,3), P2(15,9) · Computer Graphics, chapter 3
- Non-preemptive SJF with P4 arriving · Embedded System, chapter 6 · asked 2×