DEADLOCKS IN
OPERATING SYSTEM
OPERATING SYSTEM
Presented by :
Wajiha Siddiqui
Sara Ali
Aisha Hameed
1. The Deadlock Problem
2. Deadlock Characterization
3. Deadlock Modeling
4. Resource Allocation Graph
5. Methods for Handling Deadlocks
 Deadlock Prevention
 Deadlock Avoidance
 Deadlock Detection
 Recovery from Deadlock
WHAT ARE DEADLOCKS???
A set of blocked processes each
holding a resource and waiting to
acquire a resource held by another
process in the set.
o Example
 Process-1 requests the printer, gets it
 Process-2 requests the tape unit, gets it Process-1 and
 Process-1 requests the tape unit, waits Process-2 are
 Process-2 requests the printer, waits deadlocked!
FOUR CONDITIONS FOR DEADLOCKS???
1. Mutual Exclusion Condition
2. Hold & Wait Condition
3. No Preemption Condition
4. Circular Wait Condition
DEADLOCK MODELING???
Modeled with directed graphs
HOW DEADLOCKS OCCUR?
HOW DEADLOCKS CAN BE AVOIDED???
RESOURCE ALLOCATION GRAPHS???
 CIRCLES
 represents processes
 SQUARE
 represents classes of identical resources
 SMALL SQUARES DRAWN INSIDE LARGE SQUARES
 Indicate separate identical resources of each class
 If the resource allocation graph contains no cycles then there is
no deadlock in the system at that instance.
 If there is a cycle
o If there is only one instance per resource type than there is a deadlock
o If there is more than once instance for some resource type than there may
or may not be a deadlock
EXAMPLE OF A RESOURCE ALLOCATION GRAPH
HOW TO HANDLE DEADLOCKS???
• Four major areas of interest in deadlock research
- Deadlock Prevention
- Deadlock Avoidance
- Deadlock Detection
- Deadlock Recovery
DEADLOCK PREVENTION???
• Prevention eliminates one of four conditions
1. Elimination Of Mutual Exclusion
2. Elimination Of Hold & Wait Condition
3. Elimination Of No Preemption Condition
4. Elimination Of Circular Wait Condition
DEADLOCK AVOIDANCE???
• Maximum requirements of
each resource must be stated
in advance by each process.
• Two Approaches
• Two Algorithms
o Resource Allocation Algorithms
o The Banker’s Algorithm
DEADLOCK DETECTION???
• Determines if deadlock has occurred
• Identifies those processes & resources
involved in the deadlock
• Algorithms can incur significant
runtime overhead
RECOVERY FROM DEADLOCKS???
• Process Termination
o Abort all deadlocked processes.
o Abort one process at a time until
the deadlock cycle is eliminated.
• Resource Preemption
o Selecting a victim
o Rollback
o Starvation
Deadlocks in operating system

Deadlocks in operating system

  • 1.
  • 2.
    OPERATING SYSTEM Presented by: Wajiha Siddiqui Sara Ali Aisha Hameed
  • 3.
    1. The DeadlockProblem 2. Deadlock Characterization 3. Deadlock Modeling 4. Resource Allocation Graph 5. Methods for Handling Deadlocks  Deadlock Prevention  Deadlock Avoidance  Deadlock Detection  Recovery from Deadlock
  • 4.
    WHAT ARE DEADLOCKS??? Aset of blocked processes each holding a resource and waiting to acquire a resource held by another process in the set. o Example  Process-1 requests the printer, gets it  Process-2 requests the tape unit, gets it Process-1 and  Process-1 requests the tape unit, waits Process-2 are  Process-2 requests the printer, waits deadlocked!
  • 5.
    FOUR CONDITIONS FORDEADLOCKS??? 1. Mutual Exclusion Condition 2. Hold & Wait Condition 3. No Preemption Condition 4. Circular Wait Condition
  • 6.
  • 7.
  • 8.
    HOW DEADLOCKS CANBE AVOIDED???
  • 9.
    RESOURCE ALLOCATION GRAPHS??? CIRCLES  represents processes  SQUARE  represents classes of identical resources  SMALL SQUARES DRAWN INSIDE LARGE SQUARES  Indicate separate identical resources of each class
  • 10.
     If theresource allocation graph contains no cycles then there is no deadlock in the system at that instance.  If there is a cycle o If there is only one instance per resource type than there is a deadlock o If there is more than once instance for some resource type than there may or may not be a deadlock
  • 11.
    EXAMPLE OF ARESOURCE ALLOCATION GRAPH
  • 12.
    HOW TO HANDLEDEADLOCKS??? • Four major areas of interest in deadlock research - Deadlock Prevention - Deadlock Avoidance - Deadlock Detection - Deadlock Recovery
  • 13.
    DEADLOCK PREVENTION??? • Preventioneliminates one of four conditions 1. Elimination Of Mutual Exclusion 2. Elimination Of Hold & Wait Condition 3. Elimination Of No Preemption Condition 4. Elimination Of Circular Wait Condition
  • 14.
    DEADLOCK AVOIDANCE??? • Maximumrequirements of each resource must be stated in advance by each process. • Two Approaches • Two Algorithms o Resource Allocation Algorithms o The Banker’s Algorithm
  • 15.
    DEADLOCK DETECTION??? • Determinesif deadlock has occurred • Identifies those processes & resources involved in the deadlock • Algorithms can incur significant runtime overhead
  • 16.
    RECOVERY FROM DEADLOCKS??? •Process Termination o Abort all deadlocked processes. o Abort one process at a time until the deadlock cycle is eliminated. • Resource Preemption o Selecting a victim o Rollback o Starvation