SlideShare a Scribd company logo
Deadlocks
7.2
Deadlocks
● The Deadlock Problem
● System Model
● Deadlock Characterization
● Methods for Handling Deadlocks
● Deadlock Prevention
● Deadlock Avoidance
● Deadlock Detection
● Recovery from Deadlock
7.3
Chapter Objectives
● To develop a description of deadlocks, which
prevent sets of concurrent processes from
completing their tasks
● To present a number of different methods for
preventing or avoiding deadlocks in a computer
system
7.4
The Deadlock Problem
● A set of blocked processes each holding a resource and
waiting to acquire a resource held by another process in
the set
● Example
● System has 2 disk drives
● P1 and P2 each holds one disk drive and each needs
another one
● Example
● semaphores A and B, initialized to 1
P0 P1
wait (A); wait(B)
wait (B); wait(A)
7.5
Bridge Crossing Example
● Traffic only in one direction
● Each section of a bridge can be viewed as a resource
● If a deadlock occurs, it can be resolved if one car backs
up (preempt resources and rollback)
● Several cars may have to be backed up if a deadlock
occurs
● Starvation is possible
● Note – Most OSes do not prevent or deal with deadlocks
7.6
System Model
● Resource types R1, R2, . . ., Rm
CPU cycles, memory space, I/O devices
● Each resource type Ri has Wi instances.
● Each process utilizes a resource as follows:
● request
● use
● release
7.7
Deadlock Characterization
● Mutual exclusion: only one process at a time can use a
resource
● Hold and wait: a process holding at least one resource
is waiting to acquire additional resources held by other
processes
● No preemption: a resource can be released only
voluntarily by the process holding it, after that process
has completed its task
● Circular wait: there exists a set {P0, P1, …, Pn} of
waiting processes such that P0 is waiting for a resource
that is held by P1, P1 is waiting for a resource that is
held by P2, …, Pn–1 is waiting for a resource that is held
by Pn, and Pn is waiting for a resource that is held by P0.
Deadlock can arise if four conditions hold simultaneously.
7.8
Resource-Allocation Graph
● V is partitioned into two types:
● P = {P1, P2, …, Pn}, the set consisting of all the
processes in the system
● R = {R1, R2, …, Rm}, the set consisting of all
resource types in the system
● request edge – directed edge P1 → Rj
● assignment edge – directed edge Rj → Pi
A set of vertices V and a set of edges E.
7.9
Resource-Allocation Graph (Cont.)
● Process
● Resource Type with 4 instances
● Pi requests instance of Rj
● Pi is holding an instance of Rj
P
i
P
i
Rj
Rj
7.10
Example of a Resource Allocation Graph
7.11
Resource Allocation Graph With A Deadlock
7.12
Graph With A Cycle But No Deadlock
7.13
Basic Facts
● If graph contains no cycles ⇒ no deadlock
● If graph contains a cycle ⇒
● if only one instance per resource type, then
deadlock
● if several instances per resource type,
possibility of deadlock
7.14
Methods for Handling Deadlocks
● Ensure that the system will never enter a
deadlock state
● Allow the system to enter a deadlock state and
then recover
● Ignore the problem and pretend that deadlocks
never occur in the system; used by most
operating systems, including UNIX

More Related Content

Similar to Deadlock Backgroud.pptx

Deadlock
DeadlockDeadlock
Deadlock
Rajapriya82
 
Deadlock
DeadlockDeadlock
Deadlock
Rajapriya82
 
Lecture # 10-11 for deadlock operating system.ppt
Lecture # 10-11 for deadlock operating system.pptLecture # 10-11 for deadlock operating system.ppt
Lecture # 10-11 for deadlock operating system.ppt
RiaanSadiq
 
deadlock in OS.pptx
deadlock in OS.pptxdeadlock in OS.pptx
deadlock in OS.pptx
Monirul Islam
 
Deadlocks Part- I.pdf
Deadlocks Part- I.pdfDeadlocks Part- I.pdf
Deadlocks Part- I.pdf
Harika Pudugosula
 
Chapter 5(five).pdf
Chapter 5(five).pdfChapter 5(five).pdf
Chapter 5(five).pdf
amanuel236786
 
OS deadlock.pptx
OS deadlock.pptxOS deadlock.pptx
OS deadlock.pptx
rpbbhalerao2000
 
10. deadlock
10. deadlock10. deadlock
10. deadlock
Robbie AkaChopa
 
Deadlock Detection.pptx
Deadlock Detection.pptxDeadlock Detection.pptx
Deadlock Detection.pptx
infomerlin
 
Deadlock.pptx
Deadlock.pptxDeadlock.pptx
Deadlock.pptx
SasmitaDash28
 
Deadlock Detection Algorithm
Deadlock Detection AlgorithmDeadlock Detection Algorithm
Deadlock Detection Algorithm
Mohammad Qureshi
 
Sucet os module_3_notes
Sucet os module_3_notesSucet os module_3_notes
Sucet os module_3_notes
SRINIVASUNIVERSITYEN
 
Os module 2 d
Os module 2 dOs module 2 d
Os module 2 d
Gichelle Amon
 
Section07-Deadlocks (1).ppt
Section07-Deadlocks (1).pptSection07-Deadlocks (1).ppt
Section07-Deadlocks (1).ppt
amadayshwan
 
Section07-Deadlocks_operating_system.ppt
Section07-Deadlocks_operating_system.pptSection07-Deadlocks_operating_system.ppt
Section07-Deadlocks_operating_system.ppt
jbri1395
 
Deadlocks
DeadlocksDeadlocks
Deadlocks
Shipra Swati
 
Os5
Os5Os5
Galvin-operating System(Ch8)
Galvin-operating System(Ch8)Galvin-operating System(Ch8)
Galvin-operating System(Ch8)
dsuyal1
 
Dead Lock
Dead LockDead Lock
Dead Lock
Ramasubbu .P
 
Deadlock (1).ppt
Deadlock (1).pptDeadlock (1).ppt
Deadlock (1).ppt
Nusaike Mufthie
 

Similar to Deadlock Backgroud.pptx (20)

Deadlock
DeadlockDeadlock
Deadlock
 
Deadlock
DeadlockDeadlock
Deadlock
 
Lecture # 10-11 for deadlock operating system.ppt
Lecture # 10-11 for deadlock operating system.pptLecture # 10-11 for deadlock operating system.ppt
Lecture # 10-11 for deadlock operating system.ppt
 
deadlock in OS.pptx
deadlock in OS.pptxdeadlock in OS.pptx
deadlock in OS.pptx
 
Deadlocks Part- I.pdf
Deadlocks Part- I.pdfDeadlocks Part- I.pdf
Deadlocks Part- I.pdf
 
Chapter 5(five).pdf
Chapter 5(five).pdfChapter 5(five).pdf
Chapter 5(five).pdf
 
OS deadlock.pptx
OS deadlock.pptxOS deadlock.pptx
OS deadlock.pptx
 
10. deadlock
10. deadlock10. deadlock
10. deadlock
 
Deadlock Detection.pptx
Deadlock Detection.pptxDeadlock Detection.pptx
Deadlock Detection.pptx
 
Deadlock.pptx
Deadlock.pptxDeadlock.pptx
Deadlock.pptx
 
Deadlock Detection Algorithm
Deadlock Detection AlgorithmDeadlock Detection Algorithm
Deadlock Detection Algorithm
 
Sucet os module_3_notes
Sucet os module_3_notesSucet os module_3_notes
Sucet os module_3_notes
 
Os module 2 d
Os module 2 dOs module 2 d
Os module 2 d
 
Section07-Deadlocks (1).ppt
Section07-Deadlocks (1).pptSection07-Deadlocks (1).ppt
Section07-Deadlocks (1).ppt
 
Section07-Deadlocks_operating_system.ppt
Section07-Deadlocks_operating_system.pptSection07-Deadlocks_operating_system.ppt
Section07-Deadlocks_operating_system.ppt
 
Deadlocks
DeadlocksDeadlocks
Deadlocks
 
Os5
Os5Os5
Os5
 
Galvin-operating System(Ch8)
Galvin-operating System(Ch8)Galvin-operating System(Ch8)
Galvin-operating System(Ch8)
 
Dead Lock
Dead LockDead Lock
Dead Lock
 
Deadlock (1).ppt
Deadlock (1).pptDeadlock (1).ppt
Deadlock (1).ppt
 

More from infomerlin

GSC-21_029_4_09_TSDSI-R1-1.pptx
GSC-21_029_4_09_TSDSI-R1-1.pptxGSC-21_029_4_09_TSDSI-R1-1.pptx
GSC-21_029_4_09_TSDSI-R1-1.pptx
infomerlin
 
sat-ppt.pptx
sat-ppt.pptxsat-ppt.pptx
sat-ppt.pptx
infomerlin
 
Paging.ppt
Paging.pptPaging.ppt
Paging.ppt
infomerlin
 
Page Replacement Algorithms.pptx
Page Replacement Algorithms.pptxPage Replacement Algorithms.pptx
Page Replacement Algorithms.pptx
infomerlin
 
Segmentation.ppt
Segmentation.pptSegmentation.ppt
Segmentation.ppt
infomerlin
 
Allocating of Frames.pptx
Allocating of Frames.pptxAllocating of Frames.pptx
Allocating of Frames.pptx
infomerlin
 
Contiguous Memory Allocation.ppt
Contiguous Memory Allocation.pptContiguous Memory Allocation.ppt
Contiguous Memory Allocation.ppt
infomerlin
 
Allocating Kernel Memory.pptx
Allocating Kernel Memory.pptxAllocating Kernel Memory.pptx
Allocating Kernel Memory.pptx
infomerlin
 
Deadlock Prevention.pptx
Deadlock Prevention.pptxDeadlock Prevention.pptx
Deadlock Prevention.pptx
infomerlin
 
Frame detection.pdf
Frame detection.pdfFrame detection.pdf
Frame detection.pdf
infomerlin
 
5G Hackathon - Brainstorming Session.pptx
5G Hackathon - Brainstorming Session.pptx5G Hackathon - Brainstorming Session.pptx
5G Hackathon - Brainstorming Session.pptx
infomerlin
 
LNA.ppt
LNA.pptLNA.ppt
LNA.ppt
infomerlin
 
Lecture 4.pptx
Lecture 4.pptxLecture 4.pptx
Lecture 4.pptx
infomerlin
 
System Calls.ppt
System Calls.pptSystem Calls.ppt
System Calls.ppt
infomerlin
 
Lec 6 OS structure and Operations.ppt
Lec 6 OS structure and Operations.pptLec 6 OS structure and Operations.ppt
Lec 6 OS structure and Operations.ppt
infomerlin
 
cs-intro-os.ppt
cs-intro-os.pptcs-intro-os.ppt
cs-intro-os.ppt
infomerlin
 
Lecture-2 Signal-Spectra-Modulation.pptx
Lecture-2 Signal-Spectra-Modulation.pptxLecture-2 Signal-Spectra-Modulation.pptx
Lecture-2 Signal-Spectra-Modulation.pptx
infomerlin
 
Noise in AM systems.ppt
Noise in AM systems.pptNoise in AM systems.ppt
Noise in AM systems.ppt
infomerlin
 
Lecture 22 Threshold effects in FM.pptx
Lecture 22 Threshold effects in FM.pptxLecture 22 Threshold effects in FM.pptx
Lecture 22 Threshold effects in FM.pptx
infomerlin
 
Lecture-5 AM Signal Generation – Type 1.pptx
Lecture-5 AM Signal Generation – Type 1.pptxLecture-5 AM Signal Generation – Type 1.pptx
Lecture-5 AM Signal Generation – Type 1.pptx
infomerlin
 

More from infomerlin (20)

GSC-21_029_4_09_TSDSI-R1-1.pptx
GSC-21_029_4_09_TSDSI-R1-1.pptxGSC-21_029_4_09_TSDSI-R1-1.pptx
GSC-21_029_4_09_TSDSI-R1-1.pptx
 
sat-ppt.pptx
sat-ppt.pptxsat-ppt.pptx
sat-ppt.pptx
 
Paging.ppt
Paging.pptPaging.ppt
Paging.ppt
 
Page Replacement Algorithms.pptx
Page Replacement Algorithms.pptxPage Replacement Algorithms.pptx
Page Replacement Algorithms.pptx
 
Segmentation.ppt
Segmentation.pptSegmentation.ppt
Segmentation.ppt
 
Allocating of Frames.pptx
Allocating of Frames.pptxAllocating of Frames.pptx
Allocating of Frames.pptx
 
Contiguous Memory Allocation.ppt
Contiguous Memory Allocation.pptContiguous Memory Allocation.ppt
Contiguous Memory Allocation.ppt
 
Allocating Kernel Memory.pptx
Allocating Kernel Memory.pptxAllocating Kernel Memory.pptx
Allocating Kernel Memory.pptx
 
Deadlock Prevention.pptx
Deadlock Prevention.pptxDeadlock Prevention.pptx
Deadlock Prevention.pptx
 
Frame detection.pdf
Frame detection.pdfFrame detection.pdf
Frame detection.pdf
 
5G Hackathon - Brainstorming Session.pptx
5G Hackathon - Brainstorming Session.pptx5G Hackathon - Brainstorming Session.pptx
5G Hackathon - Brainstorming Session.pptx
 
LNA.ppt
LNA.pptLNA.ppt
LNA.ppt
 
Lecture 4.pptx
Lecture 4.pptxLecture 4.pptx
Lecture 4.pptx
 
System Calls.ppt
System Calls.pptSystem Calls.ppt
System Calls.ppt
 
Lec 6 OS structure and Operations.ppt
Lec 6 OS structure and Operations.pptLec 6 OS structure and Operations.ppt
Lec 6 OS structure and Operations.ppt
 
cs-intro-os.ppt
cs-intro-os.pptcs-intro-os.ppt
cs-intro-os.ppt
 
Lecture-2 Signal-Spectra-Modulation.pptx
Lecture-2 Signal-Spectra-Modulation.pptxLecture-2 Signal-Spectra-Modulation.pptx
Lecture-2 Signal-Spectra-Modulation.pptx
 
Noise in AM systems.ppt
Noise in AM systems.pptNoise in AM systems.ppt
Noise in AM systems.ppt
 
Lecture 22 Threshold effects in FM.pptx
Lecture 22 Threshold effects in FM.pptxLecture 22 Threshold effects in FM.pptx
Lecture 22 Threshold effects in FM.pptx
 
Lecture-5 AM Signal Generation – Type 1.pptx
Lecture-5 AM Signal Generation – Type 1.pptxLecture-5 AM Signal Generation – Type 1.pptx
Lecture-5 AM Signal Generation – Type 1.pptx
 

Recently uploaded

integral complex analysis chapter 06 .pdf
integral complex analysis chapter 06 .pdfintegral complex analysis chapter 06 .pdf
integral complex analysis chapter 06 .pdf
gaafergoudaay7aga
 
An improved modulation technique suitable for a three level flying capacitor ...
An improved modulation technique suitable for a three level flying capacitor ...An improved modulation technique suitable for a three level flying capacitor ...
An improved modulation technique suitable for a three level flying capacitor ...
IJECEIAES
 
BRAIN TUMOR DETECTION for seminar ppt.pdf
BRAIN TUMOR DETECTION for seminar ppt.pdfBRAIN TUMOR DETECTION for seminar ppt.pdf
BRAIN TUMOR DETECTION for seminar ppt.pdf
LAXMAREDDY22
 
Curve Fitting in Numerical Methods Regression
Curve Fitting in Numerical Methods RegressionCurve Fitting in Numerical Methods Regression
Curve Fitting in Numerical Methods Regression
Nada Hikmah
 
AI assisted telemedicine KIOSK for Rural India.pptx
AI assisted telemedicine KIOSK for Rural India.pptxAI assisted telemedicine KIOSK for Rural India.pptx
AI assisted telemedicine KIOSK for Rural India.pptx
architagupta876
 
Generative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of contentGenerative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of content
Hitesh Mohapatra
 
Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...
bijceesjournal
 
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
171ticu
 
Applications of artificial Intelligence in Mechanical Engineering.pdf
Applications of artificial Intelligence in Mechanical Engineering.pdfApplications of artificial Intelligence in Mechanical Engineering.pdf
Applications of artificial Intelligence in Mechanical Engineering.pdf
Atif Razi
 
cnn.pptx Convolutional neural network used for image classication
cnn.pptx Convolutional neural network used for image classicationcnn.pptx Convolutional neural network used for image classication
cnn.pptx Convolutional neural network used for image classication
SakkaravarthiShanmug
 
Certificates - Mahmoud Mohamed Moursi Ahmed
Certificates - Mahmoud Mohamed Moursi AhmedCertificates - Mahmoud Mohamed Moursi Ahmed
Certificates - Mahmoud Mohamed Moursi Ahmed
Mahmoud Morsy
 
Data Driven Maintenance | UReason Webinar
Data Driven Maintenance | UReason WebinarData Driven Maintenance | UReason Webinar
Data Driven Maintenance | UReason Webinar
UReason
 
Design and optimization of ion propulsion drone
Design and optimization of ion propulsion droneDesign and optimization of ion propulsion drone
Design and optimization of ion propulsion drone
bjmsejournal
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
IJECEIAES
 
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
Yasser Mahgoub
 
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.pptUnit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
KrishnaveniKrishnara1
 
artificial intelligence and data science contents.pptx
artificial intelligence and data science contents.pptxartificial intelligence and data science contents.pptx
artificial intelligence and data science contents.pptx
GauravCar
 
Seminar on Distillation study-mafia.pptx
Seminar on Distillation study-mafia.pptxSeminar on Distillation study-mafia.pptx
Seminar on Distillation study-mafia.pptx
Madan Karki
 
ITSM Integration with MuleSoft.pptx
ITSM  Integration with MuleSoft.pptxITSM  Integration with MuleSoft.pptx
ITSM Integration with MuleSoft.pptx
VANDANAMOHANGOUDA
 
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURSCompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
RamonNovais6
 

Recently uploaded (20)

integral complex analysis chapter 06 .pdf
integral complex analysis chapter 06 .pdfintegral complex analysis chapter 06 .pdf
integral complex analysis chapter 06 .pdf
 
An improved modulation technique suitable for a three level flying capacitor ...
An improved modulation technique suitable for a three level flying capacitor ...An improved modulation technique suitable for a three level flying capacitor ...
An improved modulation technique suitable for a three level flying capacitor ...
 
BRAIN TUMOR DETECTION for seminar ppt.pdf
BRAIN TUMOR DETECTION for seminar ppt.pdfBRAIN TUMOR DETECTION for seminar ppt.pdf
BRAIN TUMOR DETECTION for seminar ppt.pdf
 
Curve Fitting in Numerical Methods Regression
Curve Fitting in Numerical Methods RegressionCurve Fitting in Numerical Methods Regression
Curve Fitting in Numerical Methods Regression
 
AI assisted telemedicine KIOSK for Rural India.pptx
AI assisted telemedicine KIOSK for Rural India.pptxAI assisted telemedicine KIOSK for Rural India.pptx
AI assisted telemedicine KIOSK for Rural India.pptx
 
Generative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of contentGenerative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of content
 
Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...
 
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
 
Applications of artificial Intelligence in Mechanical Engineering.pdf
Applications of artificial Intelligence in Mechanical Engineering.pdfApplications of artificial Intelligence in Mechanical Engineering.pdf
Applications of artificial Intelligence in Mechanical Engineering.pdf
 
cnn.pptx Convolutional neural network used for image classication
cnn.pptx Convolutional neural network used for image classicationcnn.pptx Convolutional neural network used for image classication
cnn.pptx Convolutional neural network used for image classication
 
Certificates - Mahmoud Mohamed Moursi Ahmed
Certificates - Mahmoud Mohamed Moursi AhmedCertificates - Mahmoud Mohamed Moursi Ahmed
Certificates - Mahmoud Mohamed Moursi Ahmed
 
Data Driven Maintenance | UReason Webinar
Data Driven Maintenance | UReason WebinarData Driven Maintenance | UReason Webinar
Data Driven Maintenance | UReason Webinar
 
Design and optimization of ion propulsion drone
Design and optimization of ion propulsion droneDesign and optimization of ion propulsion drone
Design and optimization of ion propulsion drone
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
 
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
 
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.pptUnit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
 
artificial intelligence and data science contents.pptx
artificial intelligence and data science contents.pptxartificial intelligence and data science contents.pptx
artificial intelligence and data science contents.pptx
 
Seminar on Distillation study-mafia.pptx
Seminar on Distillation study-mafia.pptxSeminar on Distillation study-mafia.pptx
Seminar on Distillation study-mafia.pptx
 
ITSM Integration with MuleSoft.pptx
ITSM  Integration with MuleSoft.pptxITSM  Integration with MuleSoft.pptx
ITSM Integration with MuleSoft.pptx
 
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURSCompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
 

Deadlock Backgroud.pptx

  • 2. 7.2 Deadlocks ● The Deadlock Problem ● System Model ● Deadlock Characterization ● Methods for Handling Deadlocks ● Deadlock Prevention ● Deadlock Avoidance ● Deadlock Detection ● Recovery from Deadlock
  • 3. 7.3 Chapter Objectives ● To develop a description of deadlocks, which prevent sets of concurrent processes from completing their tasks ● To present a number of different methods for preventing or avoiding deadlocks in a computer system
  • 4. 7.4 The Deadlock Problem ● A set of blocked processes each holding a resource and waiting to acquire a resource held by another process in the set ● Example ● System has 2 disk drives ● P1 and P2 each holds one disk drive and each needs another one ● Example ● semaphores A and B, initialized to 1 P0 P1 wait (A); wait(B) wait (B); wait(A)
  • 5. 7.5 Bridge Crossing Example ● Traffic only in one direction ● Each section of a bridge can be viewed as a resource ● If a deadlock occurs, it can be resolved if one car backs up (preempt resources and rollback) ● Several cars may have to be backed up if a deadlock occurs ● Starvation is possible ● Note – Most OSes do not prevent or deal with deadlocks
  • 6. 7.6 System Model ● Resource types R1, R2, . . ., Rm CPU cycles, memory space, I/O devices ● Each resource type Ri has Wi instances. ● Each process utilizes a resource as follows: ● request ● use ● release
  • 7. 7.7 Deadlock Characterization ● Mutual exclusion: only one process at a time can use a resource ● Hold and wait: a process holding at least one resource is waiting to acquire additional resources held by other processes ● No preemption: a resource can be released only voluntarily by the process holding it, after that process has completed its task ● Circular wait: there exists a set {P0, P1, …, Pn} of waiting processes such that P0 is waiting for a resource that is held by P1, P1 is waiting for a resource that is held by P2, …, Pn–1 is waiting for a resource that is held by Pn, and Pn is waiting for a resource that is held by P0. Deadlock can arise if four conditions hold simultaneously.
  • 8. 7.8 Resource-Allocation Graph ● V is partitioned into two types: ● P = {P1, P2, …, Pn}, the set consisting of all the processes in the system ● R = {R1, R2, …, Rm}, the set consisting of all resource types in the system ● request edge – directed edge P1 → Rj ● assignment edge – directed edge Rj → Pi A set of vertices V and a set of edges E.
  • 9. 7.9 Resource-Allocation Graph (Cont.) ● Process ● Resource Type with 4 instances ● Pi requests instance of Rj ● Pi is holding an instance of Rj P i P i Rj Rj
  • 10. 7.10 Example of a Resource Allocation Graph
  • 12. 7.12 Graph With A Cycle But No Deadlock
  • 13. 7.13 Basic Facts ● If graph contains no cycles ⇒ no deadlock ● If graph contains a cycle ⇒ ● if only one instance per resource type, then deadlock ● if several instances per resource type, possibility of deadlock
  • 14. 7.14 Methods for Handling Deadlocks ● Ensure that the system will never enter a deadlock state ● Allow the system to enter a deadlock state and then recover ● Ignore the problem and pretend that deadlocks never occur in the system; used by most operating systems, including UNIX