Deadlocks in Operating Systems
A Complete Overview
What is a Deadlock?
• • A deadlock is a situation where a set of
processes are blocked.
• • Each process is waiting for a resource held
by another process.
• • No process can proceed.
Necessary Conditions (Coffman
Conditions)
• The following four conditions must hold
simultaneously:
• • Mutual Exclusion
• • Hold and Wait
• • No Preemption
• • Circular Wait
Resource Allocation Graph
• • Used to represent resources and processes.
• • A cycle in the graph indicates a possible
deadlock.
• • For one resource per type, cycle = deadlock.
Methods for Handling Deadlocks
• • Deadlock Prevention
• • Deadlock Avoidance
• • Deadlock Detection
• • Deadlock Recovery
Deadlock Prevention
• • Ensures at least one Coffman condition does
not occur.
• • Break one of the conditions:
• - Mutual Exclusion
• - Hold and Wait
• - No Preemption
• - Circular Wait
Deadlock Avoidance (Banker's
Algorithm)
• • Works by checking safety state.
• • Ensures system stays in safe state.
• • Allocate resources only if safe.
Deadlock Detection & Recovery
• • Detection algorithms identify cycles.
• • Recovery methods:
• - Process termination
• - Resource preemption
Real-Life Examples
• • Two trains waiting on a single-track section.
• • Two people trying to pass in a narrow
hallway.
• • Printers and scanners shared in network.

Deadlocks _ OS_ Presentation. pd.@237547

  • 1.
    Deadlocks in OperatingSystems A Complete Overview
  • 2.
    What is aDeadlock? • • A deadlock is a situation where a set of processes are blocked. • • Each process is waiting for a resource held by another process. • • No process can proceed.
  • 3.
    Necessary Conditions (Coffman Conditions) •The following four conditions must hold simultaneously: • • Mutual Exclusion • • Hold and Wait • • No Preemption • • Circular Wait
  • 4.
    Resource Allocation Graph •• Used to represent resources and processes. • • A cycle in the graph indicates a possible deadlock. • • For one resource per type, cycle = deadlock.
  • 5.
    Methods for HandlingDeadlocks • • Deadlock Prevention • • Deadlock Avoidance • • Deadlock Detection • • Deadlock Recovery
  • 6.
    Deadlock Prevention • •Ensures at least one Coffman condition does not occur. • • Break one of the conditions: • - Mutual Exclusion • - Hold and Wait • - No Preemption • - Circular Wait
  • 7.
    Deadlock Avoidance (Banker's Algorithm) •• Works by checking safety state. • • Ensures system stays in safe state. • • Allocate resources only if safe.
  • 8.
    Deadlock Detection &Recovery • • Detection algorithms identify cycles. • • Recovery methods: • - Process termination • - Resource preemption
  • 9.
    Real-Life Examples • •Two trains waiting on a single-track section. • • Two people trying to pass in a narrow hallway. • • Printers and scanners shared in network.