Professional Documents
Culture Documents
Deadlocks
Deadlocks
Deadlocks
❑ Introduction to Deadlocks
❑ Deadlock Prevention
Deadlock
• condition wherein a set of processes cannot continue executing
because each process is waiting for a resource that is being held or
used by another process within the set.
Process
P1
P1 is
P1 is currently requesting to
using R1 use R2
Resource Resource
R1 R2
P2 is P2 is currently
requesting to using R2
use R1
Process
P2
Unsafe State
• a state that may lead to a deadlock and must be avoided.
Safe State
• a state that has a scheduling order or a sequence of processes in
which every process in the sequence can complete its execution
• If a system is in safe state → no deadlocks
• P2 → P3 → P1
• P2 → P1 → P3
Banker’s Algorithm
• used to determine if the current state of the system is safe or not.
• max [ i ] – maximum number of resources that a certain process needs
to complete its execution.
• P3 → P4 → P1 → P2
A system has 4 processes and 10 resources of the same type.
Assume the following resource allocation table.
• P3 → P4 → P2 → P1
• P3 → P2 → P4 → P1