Skip to main content

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:

ProcessAllocation (R0 R1 R2 R3)Maximum claim (R0 R1 R2 R3)
P02 0 1 13 2 1 1
P11 1 0 01 2 0 2
P21 1 0 01 1 2 0
P31 0 1 03 2 1 0
P40 1 0 12 1 0 1
Is the state safe? If so, show the safe execution of the processes.

Deadlock vs indefinite postponement

PointDeadlockIndefinite postponement (starvation)
MeaningProcesses wait forever for each other's resourcesA process waits for a long, unbounded time because others are always preferred
CauseFour conditions hold together (circular wait etc.)Unfair scheduling or resource allocation policy
Processes affectedAll processes in the cycleUsually one or a few low-priority processes
Other processesCannot proceed in the setOthers continue normally
ResolutionNeeds prevention, avoidance or recoveryAging, fair policy (FCFS queue)
ExampleP holds printer, wants scanner; Q the reverseLow 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:

ProcessAllocationMaxNeed
P02 0 1 13 2 1 11 2 0 0
P11 1 0 01 2 0 20 1 0 2
P21 1 0 01 1 2 00 0 2 0
P31 0 1 03 2 1 02 2 0 0
P40 1 0 12 1 0 12 0 0 0

Work = (1, 1, 2, 0)

StepProcessNeedNeed ≤ WorkWork after
1P20 0 2 0yes1 1 2 0 + 1 1 0 0 = 2 2 2 0
2P01 2 0 0yes2 2 2 0 + 2 0 1 1 = 4 2 3 1
3P32 2 0 0yes4 2 3 1 + 1 0 1 0 = 5 2 4 1
4P42 0 0 0yes5 2 4 1 + 0 1 0 1 = 5 3 4 2
5P10 1 0 2yes5 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)

All Operating System chapter 7 questions →