Deadlocks: Ankur Gupta
Deadlocks: Ankur Gupta
Deadlocks: Ankur Gupta
Ankur Gupta
Agenda
Introduction to Deadlocks
Necessary Conditions for Deadlocks
Types of Resources
Deadlock modeling
Deadlock prevention
Deadlock avoidance
Deadlock detection and recovery
Deadlocks
Coffman (1971) proved that four conditions need to exist for Deadlocks to
occur
Preemptable resources
resources which are shared, but can be taken away
from the process
– Primary memory
– CPU
Nonpreemtable resources
resources which cannot be taken away from
processes
– Process shared data
– CD writer
– Printer
requesting
R2 Deadlock R1
holding
Process Process P1
Resource Allocation
Graphs
Deadlock modeling
• No-preemption
• Allow the OS to take away resources from blocked processes
allowing some other process to acquire the released resource
and begin execution
• Not applicable to all type of resources. For instance,
preempting a partially updated file, will result in corruption. So,
this has limited applicability
• Circular Waiting
• Linear ordering of resources into classes. A process can only
acquire a class of resources in an atomic operation and that
too in a strictly increasing order.
• Problem here is that the whole class of resources is claimed in
advance although some of the resources may not be required
or may be needed only for a short period of time. This lowers
the degree of concurrency as these resources cannot be
allocated to other processes.
Deadlock Prevention
A 3 0 1 1 A 1 1 0 0
B 0 1 0 0 B 0 1 1 2
C 1 1 1 0 C 3 1 0 0
D 1 1 0 1 D 0 0 1 0
E 0 0 0 0 E 2 1 1 0