Professional Documents
Culture Documents
Illustration of a deadlock
Conditions for Deadlock
(Deadlock Characterization)
The following 4 conditions are necessary and sufficient for
deadlock (must hold simultaneously)
Mutual Exclusion:
Only one process at a time can use the resource.
Hold and Wait:
Processes hold resources already allocated to them while
waiting for other resources.
No preemption:
Resources are released by processes holding them only after
that process has completed its task.
Circular wait:
A circular chain of processes exists in which each process
waits for one or more resources held by the next process in
the chain.
Resource Allocation Graph
The resource allocation graph is used to
describe a deadlock graphically. The
graphics has two types of nodes, process
node and resource node. Process node
represented by circle and resource node
represented by rectangle.
RESOURCE
PROCESS
Claim Graph
R1
P1 P2
R2
• P1 is using R2
• P1 is waiting for R1
• R1 is being used by P2
• P2 is waiting for R2
Graph with cycles but not deadlock
R1 P3
P1 P2
R2
Basic facts
e.g. tape drive has number 1,disk drive has no. 5 and
printer has no. 12.
A process wants to read the disk drive and printout the
result. It can not do it in reverse order.
12 Printer
05 Disk drive
1 Tape
Drive
Basic Facts
P1 P2
R2
It indicates that the resource has been allocated
to the process. After the process releases this
resource, the assignment edge is again
converted to claim edge. All claim edges of a
process are represented in the graph.
Banker’s Algorithm
Set of resources, set of customers, banker
Rules
Each customer tells banker maximum amount of money it needs.
Customer borrows money from banker.
Customer eventually pays back loan.
Banker only lends resources if the system will be in
a safe state after the loan.
Banker’s Algorithm