Ch. 5 - Deadlock Flashcards
Deadlock
Permanent blocking of a set of processes that compete for system resources
Give an example of deadlock
Various Answers
An example: Alex tries to call Will who tries to call Ryrie who tries to call Alex. All people (i.e. processes) are waiting for someone to get off hold (i.e. resource is free)
What is the best way to deal with deadlock?
It is best to prevent deadlock from happening in your code since there is no efficient general solution to the deadlock problem
What are the different categories of resources?
> Reusable
Consumable
Preemptable
Non-preemptable
Reusable Resources
Can be safely used by one process at a time and is not depleted after the process is done using it. (eg. CPU)
Consumable Resources
Resources that are created and destroyed. When it is acquired by a process, the resource does not exist after the process is done using it. (eg. interrupts)
Preemptable Resources
Can be taken away from the process owning it with no negative side effects (other than possibly runtime, but correctness is not affected). (eg. CPU)
Non-Preemptable Resources
Cannot be taken away from process owning it without affecting the process’ correctness. (eg. printer)
What categories of resources shared can lead to deadlock occurring?
Reusable and Non-Preemptable resources
What 4 conditions must hold for deadlock to occur?
> Mutual Exclusion
Hold and Wait
No preemption
Circular Wait
Mutual Exclusion (Condition for Deadlock)
Processes do not share resources (one process uses a resource at any given time)
Hold and Wait (Condition for Deadlock)
Processes may keep some resources while waiting for other resources to become available.
No Preemption (Condition for Deadlock)
Processes will not give up a resource until it is finished with it.
Circular Wait (Condition for Deadlock)
Each process in a chain hold a resource requested by another process.
Which condition for deadlock is the preferred condition to prevent?
Circular Wait. Create systems that prevent, detect, or avoid cycles.