Lecture 6 - Deadlocks Flashcards
Define a Deadlock
Permanent blocking of a set of processes that compete for system resources.
A set of processes are in a wait state, because each process is waiting for a resource that is held by some other waiting process.
All deadlocks involve conflicting resource needs by two or more processes.
Is there an efficient solution to the deadlock problem?
Not in the general case.
What are 4 classes of resource classification?
Reusable: something that can be safely used by one process at a time and is not depleted by that use. Processes obtain resources that they later release for reuse by others.
Ex: CPU, memory, specific I/O devices, or files
Consumable: These can be created and destroyed. When a resource is acquired by a process, the resource ceases to exist.
Ex: Interrupts, signals, or messages
Preemptable: these can be taken away from the process owning it with no ill effects (needs save/restore).
Ex: memory or CPU.
Non-preemptable: cannot be taken away from its current owner without causing the computation to fail.
Ex: printer or floppy disk.
Which classes of resources are prone to deadlocks?
reusable and non-preemptable
What are the 4 necessary conditions for deadlocks to be possible?
- Mutual exclusion: processes require exclusive control of its resources (not sharing)
- Hold and wait: process may wait for a resource while holding others
- No preemption: process will not give up a resource until it is finished with it
- Circular wait: each process in the chain holds a resource requested by another
For deadlocks to occur, can a process to be reset to an earlier state where resources were not held?
No
Which of the necessary conditions for deadlocks do these statements breach?
- Systems with only shared resources cannot deadlock.
- Systems that abort processes which request a resource that is in use.
- Preemptions may be possible if a process does not use its resources until it has acquired all it needs.
- Systems that detect or avoid deadlocks.
- Transaction processing systems provide checkpoints so that processes may back out of a transaction.
- Mutual exclusion
- Hold and wait
- No preemption
- Prevents cycle
- Irreversible process
Is a cycle in a resource graph sufficient with multiple unit resources? Why or why not?
No, A knot must exist—a cycle with no non-cycle outgoing path from any involved node.
What’s a resource graph knot?
A cycle with no non-cycle outgoing path from any involved node.
What are the 4 general strategies used for dealing with deadlocks
- Ignorance: pretend there is no problem at all.
- Prevention: design a system in such a way deadlock is excluded a priori.
- Avoidance: make a decision dynamically checking whether a request will, if granted, potentially lead to a deadlock or not.
- Detection: let the deadlock occur and detect when it happens, and take some action to recover after the fact.
What’s the difference between how Mathematicians and Engineers deal with deadlocks?
How does UNIX deal with it? Why?
Mathematicians: find deadlock totally unacceptable, and say that it must be prevented at all costs.
Engineers: ask how serious it is, and do not want to pay a penalty in performance and convenience.
UNIX approach:
• ignore the problem
• Prevention price is high –inconvenient restrictions
What are the 2 methods by which deadlock prevention is done?
Indirect methods –prevent the occurrence of one of the necessary conditions listed earlier.
Direct methods –prevent the occurrence of a circular wait condition.
Why do we say that deadlock prevention strategies are “conservative”?
Because we solve the problem of deadlock by limiting access to resources and by imposing restrictions on processes.
How does deadlock prevention deal with each of the 4 necessary conditions for deadlocks?
Mutual exclusion
•In general, this condition cannot be disallowed.
Hold-and-wait
•The hold and-wait condition can be prevented by requiring that a process request all its required resources at one time, and blocking the process until all requests can be granted simultaneously.
No preemption
•One solution is that if a process holding certain resources is denied a further request, that process must release its unused resources and request them again, together with the additional resource.
Circular Wait
•The circular wait condition can be prevented by defining a linear ordering of resource types. If a process has been allocated resources of type R, then it may subsequently request only those resources of types following R in the ordering.
What are the 3 approaches to Deadlock avoidance? What do these methods require?
- Resources trajectories
- Safe/unsafe states
- Dijkstra’s Banker’s algorithm
Requires that the system has some additional a priori information available.