SlideShare a Scribd company logo
1 of 14
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

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
ย 
Os module 2 d
Os module 2 dOs module 2 d
Os module 2 d
Gichelle Amon
ย 
Galvin-operating System(Ch8)
Galvin-operating System(Ch8)Galvin-operating System(Ch8)
Galvin-operating System(Ch8)
dsuyal1
ย 

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
ย 
5G Hackathon - Brainstorming Session.pptx
5G Hackathon - Brainstorming Session.pptx5G Hackathon - Brainstorming Session.pptx
5G Hackathon - Brainstorming Session.pptx
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
ย 

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

VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
SUHANI PANDEY
ย 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
MsecMca
ย 
Call Now โ‰ฝ 9953056974 โ‰ผ๐Ÿ” Call Girls In New Ashok Nagar โ‰ผ๐Ÿ” Delhi door step de...
Call Now โ‰ฝ 9953056974 โ‰ผ๐Ÿ” Call Girls In New Ashok Nagar  โ‰ผ๐Ÿ” Delhi door step de...Call Now โ‰ฝ 9953056974 โ‰ผ๐Ÿ” Call Girls In New Ashok Nagar  โ‰ผ๐Ÿ” Delhi door step de...
Call Now โ‰ฝ 9953056974 โ‰ผ๐Ÿ” Call Girls In New Ashok Nagar โ‰ผ๐Ÿ” Delhi door step de...
9953056974 Low Rate Call Girls In Saket, Delhi NCR
ย 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Kandungan 087776558899
ย 
Call Girls In Bangalore โ˜Ž 7737669865 ๐Ÿฅต Book Your One night Stand
Call Girls In Bangalore โ˜Ž 7737669865 ๐Ÿฅต Book Your One night StandCall Girls In Bangalore โ˜Ž 7737669865 ๐Ÿฅต Book Your One night Stand
Call Girls In Bangalore โ˜Ž 7737669865 ๐Ÿฅต Book Your One night Stand
amitlee9823
ย 

Recently uploaded (20)

Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
ย 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
ย 
Unit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdfUnit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdf
ย 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ย 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
ย 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
ย 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the start
ย 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
ย 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineering
ย 
Call Now โ‰ฝ 9953056974 โ‰ผ๐Ÿ” Call Girls In New Ashok Nagar โ‰ผ๐Ÿ” Delhi door step de...
Call Now โ‰ฝ 9953056974 โ‰ผ๐Ÿ” Call Girls In New Ashok Nagar  โ‰ผ๐Ÿ” Delhi door step de...Call Now โ‰ฝ 9953056974 โ‰ผ๐Ÿ” Call Girls In New Ashok Nagar  โ‰ผ๐Ÿ” Delhi door step de...
Call Now โ‰ฝ 9953056974 โ‰ผ๐Ÿ” Call Girls In New Ashok Nagar โ‰ผ๐Ÿ” Delhi door step de...
ย 
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
ย 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
ย 
Top Rated Pune Call Girls Budhwar Peth โŸŸ 6297143586 โŸŸ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth โŸŸ 6297143586 โŸŸ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth โŸŸ 6297143586 โŸŸ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth โŸŸ 6297143586 โŸŸ Call Me For Genuine Se...
ย 
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
ย 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
ย 
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
ย 
Call Girls In Bangalore โ˜Ž 7737669865 ๐Ÿฅต Book Your One night Stand
Call Girls In Bangalore โ˜Ž 7737669865 ๐Ÿฅต Book Your One night StandCall Girls In Bangalore โ˜Ž 7737669865 ๐Ÿฅต Book Your One night Stand
Call Girls In Bangalore โ˜Ž 7737669865 ๐Ÿฅต Book Your One night Stand
ย 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
ย 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
ย 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
ย 

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