SlideShare ist ein Scribd-Unternehmen logo
1 von 33
Concurrency:  Principles of Deadlock Operating Systems  Fall 2002
Processes and resources ,[object Object],[object Object],[object Object],[object Object],[object Object]
Concurrency and deadlocks ,[object Object],[object Object],[object Object],[object Object],[object Object]
Deadlock ,[object Object],[object Object],[object Object]
Deadlock in the everyday life 1 2 3 4
Deadlock in the everyday life
Deadlock when contending for the critical section
Example of Deadlock Progress of Q Release A Release B Get A Get B Get A Get B Release A Release B Progress of P A Required B Required A Required B Required deadlock inevitable 1 2 3 4 5 6 P and Q want A P and Q want B
Example of No Deadlock Progress of Q Release A Release B Get A Get B Get A Release A Get B Release B Progress of P A Required B Required A Required B Required 1 2 3 4 5 6 P and Q want A P and Q want B
Resource categories ,[object Object],[object Object],[object Object],[object Object],[object Object]
Reusable resources and Deadlock ,[object Object],[object Object],P1 . . . . . . Request 80K bytes; Request 60K bytes; P2 . . . . . . Request 70K bytes; Request 80K bytes;
Consumable resources and Deadlock ,[object Object],P1 . . . . . . Receive(P2); Send(P2); P2 . . . . . . Receive(P1); Send(P1);
Conditions for Deadlock ,[object Object],[object Object],[object Object],[object Object],[object Object],Process P1 Process P2 Requests Held by Requests Held By Resource B Resource A
Conditions for Deadlock ,[object Object],[object Object],[object Object],[object Object],DEADLOCK
Circular Wait P1 P2 P3 R1 R2 R3
No circular wait P1 P2 P3 R1 R2 R3
Coping with Deadlocks ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Deadlock prevention ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Preventing circular wait P1 P2 P3 R1 R2 R3
Deadlock prevention: Cons ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Deadlock avoidance ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Banker’s algorithm ( Dijkstra 65’ ) ,[object Object],[object Object],[object Object],[object Object]
Determination of the safe state ,[object Object],[object Object],[object Object],Claim  Allocated  Total 3  2  2 6  1  3 3  1  4 4  2  2 1  0  0 6  1  2 2  1  1 0  0  2 P1 P2 P3 P4 R1  R2  R3 R1  R2  R3 R1  R2  R3 9  3  6 Available 0  1  1
Determination of the safe state Claim  Allocated  Total 3  2  2 0  0  0 3  1  4 4  2  2 1  0  0 0  0  0 2  1  1 0  0  2 P1 P2 P3 P4 R1  R2  R3 R1  R2  R3 R1  R2  R3 9  3  6 Available 6  2  3 Claim  Allocated  Total 0  0  0 0  0  0 3  1  4 4  2  2 0  0  0 0  0  0 2  1  1 0  0  2 P1 P2 P3 P4 R1  R2  R3 R1  R2  R3 R1  R2  R3 9  3  6 Available 7  2  3
Determination of the safe state Claim  Allocated  Total 0  0  0 0  0  0 0  0  0 4  2  2 0  0  0 0  0  0 0  0  0 0  0  2 P1 P2 P3 P4 R1  R2  R3 R1  R2  R3 R1  R2  R3 9  3  6 Available 9  3  4 Claim  Allocated  Total 0  0  0 0  0  0 0  0  0 0  0  0 0  0  0 0  0  0 0  0  0 0  0  0 P1 P2 P3 P4 R1  R2  R3 R1  R2  R3 R1  R2  R3 9  3  6 Available 9  3  6 S0 is safe: P2->P1->P3->P4
Banker’s algorithm ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Banker’s algorithm Claim  Allocated  Total 3  2  2 6  1  3 3  1  4 4  2  2 1  0  0 5  1  1 2  1  1 0  0  2 P1 P2 P3 P4 R1  R2  R3 R1  R2  R3 R1  R2  R3 9  3  6 Available 1  1  2 P2 requests (1, 0, 1): Grant or not? P1 requests (1, 0, 1): Grant or not?
Deadlock detection ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Practice ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Dining philosophers problem
Dining philosophers problem ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Concurrency: summary ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Next: Memory management

Weitere ähnliche Inhalte

Was ist angesagt?

Deadlocks 160928121516-160928183232
Deadlocks 160928121516-160928183232Deadlocks 160928121516-160928183232
Deadlocks 160928121516-160928183232
marangburu42
 
Os6 2
Os6 2Os6 2
Os6 2
issbp
 

Was ist angesagt? (20)

OS - Deadlock
OS - DeadlockOS - Deadlock
OS - Deadlock
 
Chapter06
Chapter06Chapter06
Chapter06
 
Operating system Dead lock
Operating system Dead lockOperating system Dead lock
Operating system Dead lock
 
Deadlocks 160928121516-160928183232
Deadlocks 160928121516-160928183232Deadlocks 160928121516-160928183232
Deadlocks 160928121516-160928183232
 
Ch8
Ch8Ch8
Ch8
 
Deadlock
DeadlockDeadlock
Deadlock
 
Deadlocks in operating system
Deadlocks in operating systemDeadlocks in operating system
Deadlocks in operating system
 
9 deadlock
9 deadlock9 deadlock
9 deadlock
 
Deadlock ppt
Deadlock ppt Deadlock ppt
Deadlock ppt
 
Deadlock
DeadlockDeadlock
Deadlock
 
Deadlocks
 Deadlocks Deadlocks
Deadlocks
 
Deadlock- Operating System
Deadlock- Operating SystemDeadlock- Operating System
Deadlock- Operating System
 
Lect05
Lect05Lect05
Lect05
 
Deadlock in Operating System
Deadlock in Operating SystemDeadlock in Operating System
Deadlock in Operating System
 
Deadlock Avoidance in Operating System
Deadlock Avoidance in Operating SystemDeadlock Avoidance in Operating System
Deadlock Avoidance in Operating System
 
Operating system - Deadlock
Operating system - DeadlockOperating system - Deadlock
Operating system - Deadlock
 
Deadlock Presentation
Deadlock PresentationDeadlock Presentation
Deadlock Presentation
 
Deadlocks
Deadlocks Deadlocks
Deadlocks
 
23 deadlock
23 deadlock23 deadlock
23 deadlock
 
Os6 2
Os6 2Os6 2
Os6 2
 

Andere mochten auch

Operating System Deadlock Galvin
Operating System  Deadlock GalvinOperating System  Deadlock Galvin
Operating System Deadlock Galvin
Sonali Chauhan
 
Banker's note - Blackstone Synergy Pitch
Banker's note - Blackstone Synergy PitchBanker's note - Blackstone Synergy Pitch
Banker's note - Blackstone Synergy Pitch
Debashish Banerjee
 
Galvin-operating System(Ch8)
Galvin-operating System(Ch8)Galvin-operating System(Ch8)
Galvin-operating System(Ch8)
dsuyal1
 
2009 Punjab Technical University B.C.A OPERATING SYSTEM Question paper
2009 Punjab Technical University B.C.A OPERATING SYSTEM Question paper2009 Punjab Technical University B.C.A OPERATING SYSTEM Question paper
2009 Punjab Technical University B.C.A OPERATING SYSTEM Question paper
Monica Sabharwal
 
Essentials of Multithreaded System Programming in C++
Essentials of Multithreaded System Programming in C++Essentials of Multithreaded System Programming in C++
Essentials of Multithreaded System Programming in C++
Shuo Chen
 
Operating System 5
Operating System 5Operating System 5
Operating System 5
tech2click
 
Thread scheduling in Operating Systems
Thread scheduling in Operating SystemsThread scheduling in Operating Systems
Thread scheduling in Operating Systems
Nitish Gulati
 

Andere mochten auch (20)

Operating System Deadlock Galvin
Operating System  Deadlock GalvinOperating System  Deadlock Galvin
Operating System Deadlock Galvin
 
Bankers
BankersBankers
Bankers
 
Banker's note - Blackstone Synergy Pitch
Banker's note - Blackstone Synergy PitchBanker's note - Blackstone Synergy Pitch
Banker's note - Blackstone Synergy Pitch
 
Mca ii os u-3 dead lock & io systems
Mca  ii  os u-3 dead lock & io systemsMca  ii  os u-3 dead lock & io systems
Mca ii os u-3 dead lock & io systems
 
Java Threading
Java ThreadingJava Threading
Java Threading
 
thread-clustering
thread-clusteringthread-clustering
thread-clustering
 
Introduction to Operating system
Introduction to Operating systemIntroduction to Operating system
Introduction to Operating system
 
Deadlock_SVVSDM_DWD
Deadlock_SVVSDM_DWDDeadlock_SVVSDM_DWD
Deadlock_SVVSDM_DWD
 
Galvin-operating System(Ch8)
Galvin-operating System(Ch8)Galvin-operating System(Ch8)
Galvin-operating System(Ch8)
 
2009 Punjab Technical University B.C.A OPERATING SYSTEM Question paper
2009 Punjab Technical University B.C.A OPERATING SYSTEM Question paper2009 Punjab Technical University B.C.A OPERATING SYSTEM Question paper
2009 Punjab Technical University B.C.A OPERATING SYSTEM Question paper
 
Ch05
Ch05Ch05
Ch05
 
Threading
ThreadingThreading
Threading
 
C++ Actor Model - You’ve Got Mail ...
C++ Actor Model - You’ve Got Mail ...C++ Actor Model - You’ve Got Mail ...
C++ Actor Model - You’ve Got Mail ...
 
Essentials of Multithreaded System Programming in C++
Essentials of Multithreaded System Programming in C++Essentials of Multithreaded System Programming in C++
Essentials of Multithreaded System Programming in C++
 
Threads (operating System)
Threads (operating System)Threads (operating System)
Threads (operating System)
 
Operating System: Deadlock
Operating System: DeadlockOperating System: Deadlock
Operating System: Deadlock
 
Holography
HolographyHolography
Holography
 
Operating System 5
Operating System 5Operating System 5
Operating System 5
 
Unit II - 2 - Operating System - Threads
Unit II - 2 - Operating System - ThreadsUnit II - 2 - Operating System - Threads
Unit II - 2 - Operating System - Threads
 
Thread scheduling in Operating Systems
Thread scheduling in Operating SystemsThread scheduling in Operating Systems
Thread scheduling in Operating Systems
 

Ähnlich wie Lecture5

deadlock avoidance
deadlock avoidancedeadlock avoidance
deadlock avoidance
wahab13
 
OS Module-3 (2).pptx
OS Module-3 (2).pptxOS Module-3 (2).pptx
OS Module-3 (2).pptx
KokilaK25
 
DeadlockMar21.ppt
DeadlockMar21.pptDeadlockMar21.ppt
DeadlockMar21.ppt
hetrathod001
 

Ähnlich wie Lecture5 (20)

OS Presentation 1 (1).pptx
OS Presentation 1 (1).pptxOS Presentation 1 (1).pptx
OS Presentation 1 (1).pptx
 
Sucet os module_3_notes
Sucet os module_3_notesSucet os module_3_notes
Sucet os module_3_notes
 
CH07.pdf
CH07.pdfCH07.pdf
CH07.pdf
 
Deadlocks
DeadlocksDeadlocks
Deadlocks
 
7308346-Deadlock.pptx
7308346-Deadlock.pptx7308346-Deadlock.pptx
7308346-Deadlock.pptx
 
Os case study word
Os case study wordOs case study word
Os case study word
 
deadlock avoidance
deadlock avoidancedeadlock avoidance
deadlock avoidance
 
Deadlock Detection Algorithm
Deadlock Detection AlgorithmDeadlock Detection Algorithm
Deadlock Detection Algorithm
 
Chapter5_Deadlock.pptx
Chapter5_Deadlock.pptxChapter5_Deadlock.pptx
Chapter5_Deadlock.pptx
 
Gp1242 007 oer ppt
Gp1242 007 oer pptGp1242 007 oer ppt
Gp1242 007 oer ppt
 
6. Deadlock.ppt
6. Deadlock.ppt6. Deadlock.ppt
6. Deadlock.ppt
 
OS Module-3 (2).pptx
OS Module-3 (2).pptxOS Module-3 (2).pptx
OS Module-3 (2).pptx
 
Deadlocks.ppt
Deadlocks.pptDeadlocks.ppt
Deadlocks.ppt
 
Ch 4 deadlock
Ch 4 deadlockCh 4 deadlock
Ch 4 deadlock
 
Deadlock
DeadlockDeadlock
Deadlock
 
Os module 2 d
Os module 2 dOs module 2 d
Os module 2 d
 
Chapter 5(five).pdf
Chapter 5(five).pdfChapter 5(five).pdf
Chapter 5(five).pdf
 
Deadlock
DeadlockDeadlock
Deadlock
 
Deadlock
DeadlockDeadlock
Deadlock
 
DeadlockMar21.ppt
DeadlockMar21.pptDeadlockMar21.ppt
DeadlockMar21.ppt
 

Lecture5

  • 1. Concurrency: Principles of Deadlock Operating Systems Fall 2002
  • 2.
  • 3.
  • 4.
  • 5. Deadlock in the everyday life 1 2 3 4
  • 6. Deadlock in the everyday life
  • 7. Deadlock when contending for the critical section
  • 8. Example of Deadlock Progress of Q Release A Release B Get A Get B Get A Get B Release A Release B Progress of P A Required B Required A Required B Required deadlock inevitable 1 2 3 4 5 6 P and Q want A P and Q want B
  • 9. Example of No Deadlock Progress of Q Release A Release B Get A Get B Get A Release A Get B Release B Progress of P A Required B Required A Required B Required 1 2 3 4 5 6 P and Q want A P and Q want B
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15. Circular Wait P1 P2 P3 R1 R2 R3
  • 16. No circular wait P1 P2 P3 R1 R2 R3
  • 17.
  • 18.
  • 19. Preventing circular wait P1 P2 P3 R1 R2 R3
  • 20.
  • 21.
  • 22.
  • 23.
  • 24. Determination of the safe state Claim Allocated Total 3 2 2 0 0 0 3 1 4 4 2 2 1 0 0 0 0 0 2 1 1 0 0 2 P1 P2 P3 P4 R1 R2 R3 R1 R2 R3 R1 R2 R3 9 3 6 Available 6 2 3 Claim Allocated Total 0 0 0 0 0 0 3 1 4 4 2 2 0 0 0 0 0 0 2 1 1 0 0 2 P1 P2 P3 P4 R1 R2 R3 R1 R2 R3 R1 R2 R3 9 3 6 Available 7 2 3
  • 25. Determination of the safe state Claim Allocated Total 0 0 0 0 0 0 0 0 0 4 2 2 0 0 0 0 0 0 0 0 0 0 0 2 P1 P2 P3 P4 R1 R2 R3 R1 R2 R3 R1 R2 R3 9 3 6 Available 9 3 4 Claim Allocated Total 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 P1 P2 P3 P4 R1 R2 R3 R1 R2 R3 R1 R2 R3 9 3 6 Available 9 3 6 S0 is safe: P2->P1->P3->P4
  • 26.
  • 27. Banker’s algorithm Claim Allocated Total 3 2 2 6 1 3 3 1 4 4 2 2 1 0 0 5 1 1 2 1 1 0 0 2 P1 P2 P3 P4 R1 R2 R3 R1 R2 R3 R1 R2 R3 9 3 6 Available 1 1 2 P2 requests (1, 0, 1): Grant or not? P1 requests (1, 0, 1): Grant or not?
  • 28.
  • 29.
  • 31.
  • 32.