Deadlocks (week 7) Flashcards
define deadlocks
A deadlock is a situation where in a group
of two or more processes/threads, each
process holds at least one resource while
making a request on another, and all
requests cannot be satisfied because the
requested resource is held by another
process that is being blocked, waiting for
another resource.
how can deadlocks occur
–> multiprogramming environment where processes share the resources.
–> deadlocks can also occur between threads in the same process
–> Resource managers can also be involved in a deadlock with an application process
what are the 4 conditions for the deadlocks to happen
–> Mutual exclusion
–> Hold and Wait
–> Circular wait
–> No preemption
explain what is mutual exclusion in the scenario of deadlocks
–> Once a process has been allocated a
particular resource, the threads in the process have exclusive use of the resource.
–> No other processes can use a resource while it is allocated to a process.
explain what is hold and wait in the scenario of deadlocks
A process may hold a resource at the same
time it requests another one.
explain what is circular wait in the scenario of deadlocks
A situation can rise in which process p1 holds resource R1 while one of its threads requests resource R2, and process p2 holds R2 while one of its threads requests resource R1.
There may be more than two processes involved in the circular wait.
explain what is non preemption in the scenario of deadlocks
Resources can be released only by the explicit action in a process, rather than by the action of an external authority.
This assumption includes the case in which a process places a request for a resource and the resource is not available. Then the process cannot withdraw its request.
what are the 4 approaches to addressing deadlocks
prevention
avoidance
detection & recovery
manual intervention
what is prevention
–> Design the system so that
deadlock is impossible
–> Address the 4 conditions so that at least one of them does not hold. (mutual exclusion, hold and wait, circular waiting, no preemption)
–> Most common strategy is to design the resource managers so that they are guaranteed to violate at least one of the conditions.
–> for example windows NT assures that there is no circular waiting
what is avoidance
–> Manage deadlocks by allow resource
allocation only if it is satisfied that
deadlocks will not occur
–> implemented using Banker’s Algorithm.
what is Detection and Recovery
–> it is an aggressive strategy
–> Disregards deadlocks, but aims to detect
when it does occur and takes additional
steps to remove it. (recovery)
–> Therefore, we need both a detection
mechanism and a recovery mechanism.
–> For detection, an algorithm similar to
Banker’s algorithm can be used.
when to invoke the deadlock detection algorithm
–> Invoke each time a request for allocation cannot be granted immediately.
–> Invoke at regular time intervals, eg, once per hour
–> Invoke when CPU utilization drops below 40%
what is the advantage of Invoking deadlock detection algorithm each time a request for allocation cannot be granted immediately.
able to identify the specific process
that caused the deadlock
what is the disadvantage of Invoking deadlock detection algorithm each time a request for allocation cannot be granted immediately.
overhead in computation time (as you are using the cpu to check for deadlocks instead of running regular processes)
Resources allocated to deadlocked
processes will be _______ until the deadlock is broken.
idle
what are the 2 options to breaking deadlocks (deadlock recovery ) for the manual intervention method
–> Process termination
–> Resource Preemption
what are the 2 ways of doing process termination
there are 2 ways of doing process termination
–> abort all the deadlocked process
–> Abort one process at a time until the deadlock cycle is broken
why is aborting all the deadlocked process expensive
This method is expensive since processes may have computed for a long time, and all results must be discarded, and recomputed again.
why is Aborting one process at a time incurring overhead
This method incurs overhead since after each process is aborted, deadlock detection algorithm must be invoked to check whether any process is still deadlocked.
Aborting a process may not be _______
give an example of why this is the case
simple
process may be in the midst of updating a file
what must be defined in partial termination method
a policy must be defined as to which process to terminate
Factors to determine which process is chosen in process termination
–> The priority of process
–> How long the process has computed and how much longer to go
–> How many and what type of resources the process has used
–> How many more resources the process needs in order to complete
–> How many processes will need to be terminated
–> Whether the process is interactive or batch
how does Resource Preemption work ?
Preempt some resources from processes and give these resources to other processes until the deadlock cycle is broken
what happens to the resource allocated for processes when either process termination or resource preemption
methods occur
the system reclaims all resource allocated to the terminating processes.