Chapter 8 - Deadlocks Flashcards
When does deadlock occur?
Deadlock occurs in a set of processes when every process in the set is waiting for an event that can only be caused by another process in the set.
What are the four necessary conditions for deadlock?
There are four necessary conditions for deadlock:
1. mutual exclusion
2. hold and wait
3. no preemtion
4. circular wait
Deadlockk is only possible when all four conditions are present.
How can deadlocks be modeled?
Deadlocks can be modeled with resource-allocation graphs, where a cycle indicates deadlock.
How can deadlocks be prevented?
Deadlocks can be prevented by ensuring that one of the four necessary conditions for deadlock cannot occur. Of the four necessary conditions, eliminating the circular wait is the only practical approach.
How can deadlock be avoided?
Deadlock can be avoided by using the banker’s algorithm, which does not grant resources if doing so would lead the system into an unsafe state where deadlock would be possible.
What is a deadlock-detection algorithm?
A deadlock-detection algorithm can evaluate processes and resources on a running system to determine if a set of processes is in a deadlocked state.
How can a system recover from a deadlock?
If deadlock does occur, a system can attempt to recover from the deadlock by either aborting one of the processes in teh circular wait or preempting resources that have been assigned to a deadlocked process.