Deadlocks Flashcards
What is a deadlock?
Processes unable to make progress due to both waiting on the same resource
What are common causes of deadlocks?
Programming errors, wait and signal the wrong way round.
Conditions for a deadlock
Mutual exclusion
Hold and wait
No resource Preemption
Circular wait
Deadlock strategies
Prevention
Recovery
Ignore the problem
How do we prevent deadlocks?
Avoid mutual exclusion
No hold-and-wait, limit to one resource per thread.
Allow resource preemption
Circular wait, impose lock ordering.
What is mutual exclusion?
Only one process can use the resource at a given time.
How do we avoid deadlocks?
Processes declare maximum resources needed
Ensure the system is in a safe state. This occurs when there is a safe sequence of processes such that deadlock cannot occur.
How do we detect deadlocks?
Using a wait-for graph. If there are cycles, then deadlock is possible.
How do we recover from a deadlock?
Process termination, abort all deadlocks processes one at a time.
Resource pre-emption, select a victim to rollback