Os 4 Flashcards
What is a deadlock?
A deadlock is a situation where a set of processes are blocked because each process is holding a resource and waiting for another resource held by another process.
What are the four necessary conditions for deadlock to occur?
- Mutual exclusion, 2. Hold and wait, 3. No preemption, 4. Circular wait.
What is Mutual Exclusion in the context of deadlocks?
At least one resource must be held in a non-sharable mode; only one process can use it at a time.
What is Hold and Wait?
A process holding at least one resource is waiting to acquire additional resources held by other processes.
What is No Preemption?
Resources cannot be forcibly taken away from a process; they must be released voluntarily.
What is Circular Wait?
A set of processes exists such that each process is waiting for a resource held by the next process in the chain, forming a circle.
How can deadlocks be dealt with?
- Prevention, 2. Avoidance, 3. Detection and Recovery, 4. Ignoring the problem (“ostrich algorithm”).
What is deadlock prevention?
Designing a system to structurally negate one of the necessary conditions for deadlock.
How can Mutual Exclusion be prevented?
It is generally difficult since some resources inherently require exclusive access (e.g., printers).
How can Hold and Wait be prevented?
Require processes to request all resources at once before starting execution, or release all resources before requesting new ones.
How can No Preemption be prevented?
If a process holding some resources requests another resource that cannot be immediately allocated, it must release its held resources.
How can Circular Wait be prevented?
Impose a total ordering of all resource types and require that processes request resources in increasing order.
What is deadlock avoidance?
Dynamically examining resource-allocation state to ensure that a system will never enter an unsafe state.
What is a safe state?
A state where there is a sequence of all processes such that each process can finish even if all of its requested resources are granted immediately.
What is the Banker’s Algorithm?
A deadlock avoidance algorithm that allocates resources only if the system will remain in a safe state afterward.
What are the requirements of the Banker’s Algorithm?
Knowledge of maximum resource needs of each process in advance and ability to check for safe state dynamically.
What is deadlock detection?
Allowing deadlocks to occur but having a mechanism to detect them and recover.
What is a resource allocation graph?
A directed graph representing processes and resources; a cycle in this graph indicates a deadlock.
How does a deadlock detection algorithm work?
It periodically examines the resource allocation graph or uses matrices to detect cycles or unresolvable resource requests.
What is deadlock recovery?
Taking action to break the deadlock after detection, typically by terminating or preempting processes.
What are two methods for deadlock recovery?
- Process Termination, 2. Resource Preemption.
What are the risks of killing processes to recover from deadlock?
Possible data loss, inconsistent system state, and difficulty deciding which process to terminate.
How can resource preemption break a deadlock?
Temporarily removing resources from one or more processes, rolling back their execution, and allowing the deadlocked cycle to be broken.
What is the “Ostrich Algorithm” in deadlock management?
Choosing to ignore deadlock detection and recovery altogether because deadlocks are very rare and the cost of handling them is high.