Deadlocks Flashcards
A deadlock is a set of __________ each holding a resource and waiting to acquire a resource held by another _______
processes, process
What are 2 reasons why deadlocks occur?
- Complex dependencies
- Encapsulation
Complex dependencies can cause deadlocks because it’s easy to create _________ _____________
circular dependencies
____________ can cause deadlocks because each module hides its implementation details without coordinating with other modules
Encapsulation
What four conditions if held simultaneously MAY cause a deadlock?
- Mutual exclusion
- Hold and wait
- No preemption
- Circular Wait
What is mutual exclusion?
Threads requiring exclusive control of resources
What is hold and wait?
hreads are already holding resources but also are waiting for additional resources being held by other threads
What does no preemption mean?
resource released only voluntarily by the thread holding it
What is circular wait?
here exists a set {P0, P1, …, Pn} of processes such that P0 is waiting for a resource that is held by P1, P1 is waiting for P2, …, Pn–1 is waiting Pn, and Pn is waiting for P0
What are 3 methods to avoid or recover from deadlocks?
- Prevention (ensure one condition does not hold)
- Avoidance
- Detection and recovery
To prevent circular wait, we enforce that each thread requests resources in a ________ _______. We impose a _______ ________ on all resource types
consistent order, total ordering
To prevent hold and wait, we acquire ____ locks ___________
all, atomically
A disadvantage in preventing hold and wait is that we must know which locks to acquire in ________ and it decreases _________
advance, concurrency
To prevent no preemption, we make processes that fail to get a lock _____ __ all already-holding lock and _______
give up, retry
To prevent no preemption, we can specify a _______ for a thread if it does not get all its locks
timeout