Deadlocks
Deadlocks
Sanghamitra Mishra
Deadlocks
● Two or more processes wait for a resource or an event which would never happen.
Deadlocks vs Starvation
Deadlock Starvation
● Cycle present
● Deadlock
Resource Allocation Graph (contd.)
● Cycle present
● No Deadlock
Necessary and sufficient conditions for Deadlock to occur
1. Mutual Exclusion: Only one process can use a resource at a time
2. Hold & Wait: Every process holds at least 1 resource and waits for another resource
● !(Mutual exclusion)
● !(Hold & Wait)
● !(No-preemption)
● !(Circular wait)
Deadlock Ignorance
● Shut down the system and restart again
● Drawback:
and the current holdings of each process, the number of resources, total instances of
every resource.
● Resource Preemption
○ A process is chosen and preempted along with its corresponding
resources, till we reach a Safe state