deadlock
A set of processes is deadlocked if:
- Each process in the set waiting for an event
- That event can be caused only by another
process
livelock
operations are being executed but no progress is made
conditions for resource deadlocks
mutual exclusion
each resource is assigned to at most one process
hold and wait
processes can request a resource when holding another one
no preemption
resources cannot be taken away from a process
circular wait condition
chain of two or more processes must be waiting for a resource held by next process in the chain
deadlock handling
ignore the problem
no action taken
the OS doesn’t handle deadlocks, it is up to the programmer, i.e. manual
deadlock detection
detect deadlock and perform recovery actions
algorithm for detection + algorithm/mechanism for recovery
deadlock avoidance
carefully allocate resources to avoid deadlocks
requires additional information about resources a process might need during its lifeitme
deadlock prevention
structurally prevent any of the deadlock conditions
provides a method for ensuring at least one of the 4 conditions cannot hold
recovery from a deadlock
force preemption
checkpoint-rollback
killing the offending process
killing the offending process
issues with aborting a process
it was modifying a file→ it leaves a file in an incorrect state
force preemption
deadlock avoidance
Banker’s algorithm
deadlock prevention with mutual exlusion
deadlock prevention with hold and wait
deadlock prevention with no preemption
deadlock prevention with circular wait
deadlock handling in practice
deadlock avoidance: rarely an option (hard to know a resource a priori)
deadlock prevention: adopted in particular domains
ignore the problem: last resort when nothing is available
deadlock detection: solution of choice when adequate detection (and recovery) mechanism are available
global OOM killer