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