Operating Systems

Table of Contents

Deadlocks

A set of processes is deadlocked if each process in the set is waiting for an event that only another process in the set can cause.

Starvation: nobody gets resources? Livelock: many instructions executed but no progress

Conditions:

screenshot.pngscreenshot.png

Handling:

Ignore the problem

become an ostrich and imagine the problem doesn’t exist.

assumes deadlocks are rare, the cost of handling them is high, and their effects are ok.

in practice, only last resort.

Deadlock detection

can be used when simple & efficient detection mechanisms are available.

detection

recovery

in practice, solution of choice when adequate detection/recovery mechanisms are available

Deadlock prevention

mutual exclusion:

hold & wait

no preemption:

circular wait:

in practice, adopted in particular domains (e.g. two-phase locking in transaction processing systems)

Deadlock avoidance

single resource: Banker’s algorithm (Dijkstra)

multiple resources:

screenshot.png

in practice, rarely an option (hard to determine resource needs in advance)