Operating Systems Chapter 5 Process Deadlocks
Restricted Banker's Algorithm
If process p requests
process vertex
corresponds to a process and is represented by a circle.
Banker's algorithm approach
each process must first declare the max number of resources needed when the process is created.
Deadlock prevention or avoidance
ensures that the system never becomes deadlocked
solid edge
from a process vertex represents a request by this process to use on instance of the resource. From a resource vertex to a process vertex represents an assignment (or allocation) of an instance of this resource to the process.
segmented edge
from a process vertex to a resource vertex represents a future request by this process to use on instance of the resource. Also known as "claim edge"
Resource Allocation Graph
is a directed graph with two types of vertices and several types of edges. Absence of a cycle in the graph implies there is no deadlock
Deadlock
is a situation where two or more processes are waiting indefinitely for an event that can be caused only by one of the waiting processes.
Deadlock prevention
-Make all resource sharable (not possible in general) - Do not allow a process holding some resources to request and wait for other resources (disallows hold and wait condition for a deadlock to exist). First way to Implement this by requiring each process to request all needed resources at the beginning. Second way is to require each process to request resources only when it has none. -Allow preemption: When requesting a resource, a process must give the resources that its holding and request them again later -Linearly order the resources to prevent a circular wait.
Conditions for deadlock
-Non-sharable resources -No preemption (resources are released voluntarily by processes) -Circular waiting: process 0 waiting for recourse held by process 1, process 1 waiting for resource held by process 2,..., process n waiting for recourse held by process 0.
Deadlock Avoidance
Banker's algorithm approach
Deadlock detection or recovery
allows deadlocks to occur while running a detection algorithm regular or on-demand and then recovers from the detached deadlock
resource vertex
represented graphically by a rectangle, for each resource type has dots in it each corresponding to one resource instance of this type.