SlideShare a Scribd company logo
1 of 13
Karam Butt
DEADLOCK AVOIDANCE
Contents
 Deadlock Avoidance
 Safe state
 Unsafe state
 Resource allocation graph algorithm
 Banker’s Algorithm
Deadlock Avoidance
 Deadlock avoidance is a technique used to avoid
deadlock.
 It requires information about how different processes
would request different resources.
 Safe state: if deadlock not occur then safe state.
 Unsafe state: if deadlock occur then unsafe state.
 The idea of avoiding a deadlock is simply not allow the
system to enter an unsafe state the may cause a
deadlock.
Resource Allocation Graph
Algorithim
 Claim edge: used to indicate that process may request a
resource in future..
 It represented by dashed lined.
 Claim edge converts to Assignment edge when a process
requests a resource.
 Assignment Edge is represented by solid line.
 When a resource is released by a process, assignment edge
reconverts to a claim edge.
Example Resource-Allocation Graph For Deadlock
Avoidance
 Safe state:
Example Resource-Allocation Graph For Deadlock
Avoidance
 Unsafe
Banker’s Alghorithum
 Multiple instances.
 Each process must a priori claim maximum use.
 When a process requests a resource it may have to
wait.
 When a process gets all its resources it must return
them in a finite amount of time.
Example Banker’s Algorithm
Example: If we
Process A B C D
P1 2 0 1 1
P2 0 1 0 0
P3 1 0 1 1
P4 1 1 0 1
Allocation Matrix
Available
resource(5,2,4,3)
Allocation resources
(4,2,2,3)
Need matrix
Process A B C D
P1 1 1 0 0
P2 0 1 1 2
P3 3 1 0 0
P4 0 0 1 0
Solve the Example
 Available free resources=Available resource –Allocated
resources
Available free resources=(5,2,4,3)-(4,2,2,3)
Available free resources=(1,0,2,0)
Working of Banker’s Algorithm:
Need Resources <=Available free Resources(when
the condition is satisfied then processes in safe state
otherwise not.)
For p1: (1,1,0,0)<=(1,0,2,0)
Unsafe state (not Available)
Continue………
 For p2: (0,1,1,2)<=(1,0,2,0)
Unsafe(Not Available)
 For p3: (3,,1,0,0)<=(1,0,2,0)
Unsafe(Not Available)
For p4: (0,,0,1,0)<=(1,0,2,0)
(Available) Safe
Now the process p4 complete, it will turn over currently
allocated resources ,incrementing the available free
resources..
 Updated value of Available Resource=Current
value of available Resources + Allocated resources
of Allocated matrix
Need process(p1)=(1,1,0,0)<=(2,1,2,1) Available
Now p1 is complete, it will turn over currently allocated
resources ,incrementing the available free resources..
(1.1,0,1) Allocation of process(p4)
(2,1,2,1) updated value of Available
(2,1,2,1) Current value of Available
(2,0,1,1) Allocation process (P1)
(4,1,3,2) Updated value of Available

More Related Content

What's hot

What's hot (20)

contiguous memory allocation.pptx
contiguous memory allocation.pptxcontiguous memory allocation.pptx
contiguous memory allocation.pptx
 
Mainframe systems
Mainframe systemsMainframe systems
Mainframe systems
 
Cpu scheduling in operating System.
Cpu scheduling in operating System.Cpu scheduling in operating System.
Cpu scheduling in operating System.
 
Memory Management in OS
Memory Management in OSMemory Management in OS
Memory Management in OS
 
Concurrency control
Concurrency controlConcurrency control
Concurrency control
 
Methods for handling deadlock
Methods for handling deadlockMethods for handling deadlock
Methods for handling deadlock
 
Memory management
Memory managementMemory management
Memory management
 
17. Recovery System in DBMS
17. Recovery System in DBMS17. Recovery System in DBMS
17. Recovery System in DBMS
 
Distributed File Systems
Distributed File Systems Distributed File Systems
Distributed File Systems
 
Specification-of-tokens
Specification-of-tokensSpecification-of-tokens
Specification-of-tokens
 
2 phase locking protocol DBMS
2 phase locking protocol DBMS2 phase locking protocol DBMS
2 phase locking protocol DBMS
 
deadlock avoidance
deadlock avoidancedeadlock avoidance
deadlock avoidance
 
Swap-space Management
Swap-space ManagementSwap-space Management
Swap-space Management
 
Pci,usb,scsi bus
Pci,usb,scsi busPci,usb,scsi bus
Pci,usb,scsi bus
 
Demand paging
Demand pagingDemand paging
Demand paging
 
Semophores and it's types
Semophores and it's typesSemophores and it's types
Semophores and it's types
 
Deadlock
DeadlockDeadlock
Deadlock
 
Deadlock Prevention
Deadlock PreventionDeadlock Prevention
Deadlock Prevention
 
Operating System: Deadlock
Operating System: DeadlockOperating System: Deadlock
Operating System: Deadlock
 
Deadlock in Distributed Systems
Deadlock in Distributed SystemsDeadlock in Distributed Systems
Deadlock in Distributed Systems
 

Viewers also liked

Viewers also liked (20)

Unsafe SSL webinar
Unsafe SSL webinarUnsafe SSL webinar
Unsafe SSL webinar
 
Are you as safe as you think
Are you as safe as you thinkAre you as safe as you think
Are you as safe as you think
 
Operating System Deadlock Galvin
Operating System  Deadlock GalvinOperating System  Deadlock Galvin
Operating System Deadlock Galvin
 
Dead Lock
Dead LockDead Lock
Dead Lock
 
Deadlock ppt
Deadlock ppt Deadlock ppt
Deadlock ppt
 
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
 
Intro to Deadlocks
Intro to DeadlocksIntro to Deadlocks
Intro to Deadlocks
 
Ch8 OS
Ch8 OSCh8 OS
Ch8 OS
 
Deadlocks in operating system
Deadlocks in operating systemDeadlocks in operating system
Deadlocks in operating system
 
Deadlocks
 Deadlocks Deadlocks
Deadlocks
 
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
 
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
 
OS - Deadlock
OS - DeadlockOS - Deadlock
OS - Deadlock
 
Lecture5
Lecture5Lecture5
Lecture5
 
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
 
Deadlock
DeadlockDeadlock
Deadlock
 
Chapter 8 software testing
Chapter 8 software testingChapter 8 software testing
Chapter 8 software testing
 
Holography
HolographyHolography
Holography
 

Similar to Operating system Dead lock

Similar to Operating system Dead lock (20)

Deadlock
DeadlockDeadlock
Deadlock
 
Operating System
Operating SystemOperating System
Operating System
 
CH07.pdf
CH07.pdfCH07.pdf
CH07.pdf
 
Gp1242 007 oer ppt
Gp1242 007 oer pptGp1242 007 oer ppt
Gp1242 007 oer ppt
 
Chapter 5(five).pdf
Chapter 5(five).pdfChapter 5(five).pdf
Chapter 5(five).pdf
 
Ice
IceIce
Ice
 
OS_Ch8
OS_Ch8OS_Ch8
OS_Ch8
 
OSCh8
OSCh8OSCh8
OSCh8
 
Chapter 7 - Deadlocks
Chapter 7 - DeadlocksChapter 7 - Deadlocks
Chapter 7 - Deadlocks
 
Deadlock
DeadlockDeadlock
Deadlock
 
Module-2Deadlock.ppt
Module-2Deadlock.pptModule-2Deadlock.ppt
Module-2Deadlock.ppt
 
OSLec14&15(Deadlocksinopratingsystem).pptx
OSLec14&15(Deadlocksinopratingsystem).pptxOSLec14&15(Deadlocksinopratingsystem).pptx
OSLec14&15(Deadlocksinopratingsystem).pptx
 
Deadlock
DeadlockDeadlock
Deadlock
 
OS - Unit 3 Deadlock (Bankers Algorithm).pptx
OS - Unit 3 Deadlock (Bankers Algorithm).pptxOS - Unit 3 Deadlock (Bankers Algorithm).pptx
OS - Unit 3 Deadlock (Bankers Algorithm).pptx
 
Module 3 Deadlocks.pptx
Module 3 Deadlocks.pptxModule 3 Deadlocks.pptx
Module 3 Deadlocks.pptx
 
Deadlock Detection Algorithm
Deadlock Detection AlgorithmDeadlock Detection Algorithm
Deadlock Detection Algorithm
 
The implementation of Banker's algorithm, data structure and its parser
The implementation of Banker's algorithm, data structure and its parserThe implementation of Banker's algorithm, data structure and its parser
The implementation of Banker's algorithm, data structure and its parser
 
Sucet os module_3_notes
Sucet os module_3_notesSucet os module_3_notes
Sucet os module_3_notes
 
Mch7 deadlock
Mch7 deadlockMch7 deadlock
Mch7 deadlock
 
Dead lock
Dead lockDead lock
Dead lock
 

Recently uploaded

8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech studentsHimanshiGarg82
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfonteinmasabamasaba
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastPapp Krisztián
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionOnePlan Solutions
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesVictorSzoltysek
 
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburgmasabamasaba
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfkalichargn70th171
 
SHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions PresentationSHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions PresentationShrmpro
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrandmasabamasaba
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfVishalKumarJha10
 

Recently uploaded (20)

8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
SHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions PresentationSHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions Presentation
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 

Operating system Dead lock

  • 2. DEADLOCK AVOIDANCE Contents  Deadlock Avoidance  Safe state  Unsafe state  Resource allocation graph algorithm  Banker’s Algorithm
  • 3. Deadlock Avoidance  Deadlock avoidance is a technique used to avoid deadlock.  It requires information about how different processes would request different resources.  Safe state: if deadlock not occur then safe state.  Unsafe state: if deadlock occur then unsafe state.  The idea of avoiding a deadlock is simply not allow the system to enter an unsafe state the may cause a deadlock.
  • 4. Resource Allocation Graph Algorithim  Claim edge: used to indicate that process may request a resource in future..  It represented by dashed lined.  Claim edge converts to Assignment edge when a process requests a resource.  Assignment Edge is represented by solid line.  When a resource is released by a process, assignment edge reconverts to a claim edge.
  • 5. Example Resource-Allocation Graph For Deadlock Avoidance  Safe state:
  • 6. Example Resource-Allocation Graph For Deadlock Avoidance  Unsafe
  • 7. Banker’s Alghorithum  Multiple instances.  Each process must a priori claim maximum use.  When a process requests a resource it may have to wait.  When a process gets all its resources it must return them in a finite amount of time.
  • 8. Example Banker’s Algorithm Example: If we Process A B C D P1 2 0 1 1 P2 0 1 0 0 P3 1 0 1 1 P4 1 1 0 1 Allocation Matrix Available resource(5,2,4,3) Allocation resources (4,2,2,3)
  • 9. Need matrix Process A B C D P1 1 1 0 0 P2 0 1 1 2 P3 3 1 0 0 P4 0 0 1 0
  • 10. Solve the Example  Available free resources=Available resource –Allocated resources Available free resources=(5,2,4,3)-(4,2,2,3) Available free resources=(1,0,2,0) Working of Banker’s Algorithm: Need Resources <=Available free Resources(when the condition is satisfied then processes in safe state otherwise not.) For p1: (1,1,0,0)<=(1,0,2,0) Unsafe state (not Available)
  • 11. Continue………  For p2: (0,1,1,2)<=(1,0,2,0) Unsafe(Not Available)  For p3: (3,,1,0,0)<=(1,0,2,0) Unsafe(Not Available) For p4: (0,,0,1,0)<=(1,0,2,0) (Available) Safe Now the process p4 complete, it will turn over currently allocated resources ,incrementing the available free resources..
  • 12.  Updated value of Available Resource=Current value of available Resources + Allocated resources of Allocated matrix Need process(p1)=(1,1,0,0)<=(2,1,2,1) Available Now p1 is complete, it will turn over currently allocated resources ,incrementing the available free resources.. (1.1,0,1) Allocation of process(p4) (2,1,2,1) updated value of Available
  • 13. (2,1,2,1) Current value of Available (2,0,1,1) Allocation process (P1) (4,1,3,2) Updated value of Available