SlideShare a Scribd company logo
1 of 26
DEADLOCK
Group Member
• Sehrish Ishaq
• Syed Muhammad Ali Shah
• Ijlal Ahmed
Contents:
1. Introduction
2. Strategies for handling Deadlock
3. States Of Deadlock
4. Conditions For Deadlock
5. Banking Algorithm
6. Resources Allocation Graph
7. Single And Multiple Instance
DEADLOCK
If two or more process are waiting on happening of some
events, which never happens, then we say these process
are involved in deadlock then that state is called Dead Lock
Strategies For Handling Deadlock
• Prevention
• Avoidance
• Detection and Recovery
• Ignorance
1. Deadlock prevention
• Deadlock happens only when Mutual Exclusion, hold and
wait, No preemption and circular wait holds
simultaneously. If it is possible to violate one of the four
conditions at any time then the deadlock can never occur
in the system.
• The idea behind the approach is very simple that we have
to fail one of the four conditions but there can be a big
argument on its physical implementation in the system.
2.Deadlock Avoidance
• In deadlock avoidance, the operating system checks
whether the system is in safe state or in unsafe state at
every step which the operating system performs. The
process continues until the system is in safe state. Once
the system moves to unsafe state, the OS has to
backtrack one step.
• In simple words, The OS reviews each allocation so that
the allocation doesn't cause the deadlock in the system.
3.Deadlock Ignorance
• Deadlock Ignorance is the most widely used
approach among all the mechanism. This is being
used by many operating systems mainly for end user
uses. In this approach, the Operating system assumes
that deadlock never occurs. It simply ignores
deadlock. This approach is best suitable for a single
end user system where User uses the system only for
browsing and all other normal stuff.
4. Deadlock detection and recovery
• This approach let the processes fall in deadlock and
then periodically check whether deadlock occur in
the system or not. If it occurs then it applies some of
the recovery methods to the system to get rid of
deadlock.
States Of Deadlock
 There are some techniques used to avoid deadlocks.
There are two states involved in it.
• Safe state
• Unsafe state
• Safe state: Safe State is when there is no chance of
deadlock occurring,
• Unsafe state: while unsafe state doesn't mean a
deadlock has occurred yet, but means that a
deadlock could happen.
Conditions Of Deadlock
• Mutual Exclusion
• No preemption
• Hold and Wait
• Circular Wait
Mutual Exclusion
• Mutual section from the resource point of view is the
fact that a resource can never be used by more than
one process simultaneously which is fair enough but
that is the main reason behind the deadlock.
No Preemption
• Deadlock arises due to the fact that a process can't be
stopped once it starts. However, if we take the
resource away from the process which is causing
deadlock then we can prevent deadlock.
Hold and Wait
• Hold and wait condition lies when a process holds a resource
and waiting for some other resource to complete its task.
Deadlock occurs because there can be more than one process
which are holding one resource and waiting for other
Circular Wait
• To violate circular wait, we can assign a priority number to
each of the resource. A process can't request for a lesser
priority resource. This ensures that not a single process can
request a resource which is being utilized by some other
process and no cycle will be formed.
P1
P2
P3
R1 R2 R3
Banking Algorithm
• The banker’s algorithm is a resource allocation and
deadlock avoidance algorithm that tests for safety by
simulating the allocation for predetermined
maximum possible amounts of all resources
Data structures for Bank Algorithm
• Available
• Max
• Allocation
• Need
A=10 ,B= 5,C=7
Process Allocation Max Need Available Remaining
Need
A B C A B C A B C A B C
P1 0 1 0 7 5 3 3 3 2 7 4 3 P1
P2 2 0 0 3 2 2 5 3 2 1 2 2 P2
P3 3 0 2 9 0 2 7 4 3 6 0 0 P3
P4 2 1 1 4 2 2 7 4 5 2 1 1 P4
P5 0 0 2 5 3 3 7 5 5 5 3 1 P5
7 2 5 10 5 7
Resource Allocation Graph
1.Single Instance
2.Multiple Instance
Resource Allocation Graph
Vertex Edge
Process vertex Resource Vertex Assign Edge Request Edge
Single Instance Multi Instance
. . . . . . . .
P P
R R
Single Instance(Deadlock Occur)
Allocate Request
R1 R2 R1 R2
P1 1 0 0 1
P2 0 1 1 0
R1
R2
P
1
P
2
Single Instance(Not Deadlock Occur)
Allocation Request
R1 R2 R1 R2
P1 1 0 0 0
P2 0 1 0 0
P3 0 0 1 1
p1 P2 P3
R1 R2
Multi Instance
Allocate Request
R1 R2 R1 R2
P1 1 0 0 1
P2 0 1 1 0
P3 0 1 0 0
.R1
P2P1
..R2 P3
• THANK YOU

More Related Content

What's hot

Operating system 24 mutex locks and semaphores
Operating system 24 mutex locks and semaphoresOperating system 24 mutex locks and semaphores
Operating system 24 mutex locks and semaphoresVaibhav Khanna
 
Deadlock Detection in Distributed Systems
Deadlock Detection in Distributed SystemsDeadlock Detection in Distributed Systems
Deadlock Detection in Distributed SystemsDHIVYADEVAKI
 
Deadlock Avoidance - OS
Deadlock Avoidance - OSDeadlock Avoidance - OS
Deadlock Avoidance - OSMsAnita2
 
Chapter 14 replication
Chapter 14 replicationChapter 14 replication
Chapter 14 replicationAbDul ThaYyal
 
Deadlock in Distributed Systems
Deadlock in Distributed SystemsDeadlock in Distributed Systems
Deadlock in Distributed SystemsPritom Saha Akash
 
Semaphores OS Basics
Semaphores OS BasicsSemaphores OS Basics
Semaphores OS BasicsShijin Raj P
 
deadlock handling
deadlock handlingdeadlock handling
deadlock handlingSuraj Kumar
 
Transaction Management - Deadlock Handling
Transaction Management - Deadlock HandlingTransaction Management - Deadlock Handling
Transaction Management - Deadlock Handlingkavitha muneeshwaran
 
OS Process Synchronization, semaphore and Monitors
OS Process Synchronization, semaphore and MonitorsOS Process Synchronization, semaphore and Monitors
OS Process Synchronization, semaphore and Monitorssgpraju
 
Deadlock detection & prevention
Deadlock detection & preventionDeadlock detection & prevention
Deadlock detection & preventionIkhtiarUddinShaHin
 
Dead Lock In Operating Systems
Dead Lock In Operating SystemsDead Lock In Operating Systems
Dead Lock In Operating Systemstotallooser
 

What's hot (20)

Deadlock
DeadlockDeadlock
Deadlock
 
Bankers algorithm
Bankers algorithmBankers algorithm
Bankers algorithm
 
Operating system 24 mutex locks and semaphores
Operating system 24 mutex locks and semaphoresOperating system 24 mutex locks and semaphores
Operating system 24 mutex locks and semaphores
 
Deadlock Detection in Distributed Systems
Deadlock Detection in Distributed SystemsDeadlock Detection in Distributed Systems
Deadlock Detection in Distributed Systems
 
Deadlock Avoidance - OS
Deadlock Avoidance - OSDeadlock Avoidance - OS
Deadlock Avoidance - OS
 
Chapter 7 - Deadlocks
Chapter 7 - DeadlocksChapter 7 - Deadlocks
Chapter 7 - Deadlocks
 
Chapter 14 replication
Chapter 14 replicationChapter 14 replication
Chapter 14 replication
 
Operating System: Deadlock
Operating System: DeadlockOperating System: Deadlock
Operating System: Deadlock
 
Bankers
BankersBankers
Bankers
 
Deadlock in Distributed Systems
Deadlock in Distributed SystemsDeadlock in Distributed Systems
Deadlock in Distributed Systems
 
Semaphores OS Basics
Semaphores OS BasicsSemaphores OS Basics
Semaphores OS Basics
 
deadlock handling
deadlock handlingdeadlock handling
deadlock handling
 
Transaction Management - Deadlock Handling
Transaction Management - Deadlock HandlingTransaction Management - Deadlock Handling
Transaction Management - Deadlock Handling
 
Mutual exclusion and sync
Mutual exclusion and syncMutual exclusion and sync
Mutual exclusion and sync
 
OS Process Synchronization, semaphore and Monitors
OS Process Synchronization, semaphore and MonitorsOS Process Synchronization, semaphore and Monitors
OS Process Synchronization, semaphore and Monitors
 
Deadlock
DeadlockDeadlock
Deadlock
 
Deadlock detection & prevention
Deadlock detection & preventionDeadlock detection & prevention
Deadlock detection & prevention
 
Deadlocks
DeadlocksDeadlocks
Deadlocks
 
Deadlock
DeadlockDeadlock
Deadlock
 
Dead Lock In Operating Systems
Dead Lock In Operating SystemsDead Lock In Operating Systems
Dead Lock In Operating Systems
 

Similar to Deadlock Slides

Unit 3 part 2(DEADLOCK)
Unit 3 part 2(DEADLOCK)Unit 3 part 2(DEADLOCK)
Unit 3 part 2(DEADLOCK)WajeehaBaig
 
osvishal-160830131208 (1).pdf
osvishal-160830131208 (1).pdfosvishal-160830131208 (1).pdf
osvishal-160830131208 (1).pdfamadayshwan
 
OS Presentation 1 (1).pptx
OS Presentation 1 (1).pptxOS Presentation 1 (1).pptx
OS Presentation 1 (1).pptxFahadAbdullah84
 
Os case study word
Os case study wordOs case study word
Os case study wordDhol Yash
 
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 parserMatthew Chang
 
3.6 Deadlock-operating system unit 3.pptx
3.6 Deadlock-operating system unit 3.pptx3.6 Deadlock-operating system unit 3.pptx
3.6 Deadlock-operating system unit 3.pptxsvulasal
 
DEADLOCK PREVENTION AND AVOIDANCE.pptx
DEADLOCK PREVENTION AND AVOIDANCE.pptxDEADLOCK PREVENTION AND AVOIDANCE.pptx
DEADLOCK PREVENTION AND AVOIDANCE.pptxPugalenthiSomasundar
 
osvzjsjjdndnnssnnsnsndndndnndeadlock.pptx
osvzjsjjdndnnssnnsnsndndndnndeadlock.pptxosvzjsjjdndnnssnnsnsndndndnndeadlock.pptx
osvzjsjjdndnnssnnsnsndndndnndeadlock.pptxBhaskar271887
 
Deadlock in Operating System
Deadlock in Operating SystemDeadlock in Operating System
Deadlock in Operating SystemAUST
 
4.3 Deadlock [Autosaved].pptx
4.3 Deadlock [Autosaved].pptx4.3 Deadlock [Autosaved].pptx
4.3 Deadlock [Autosaved].pptxDishaDwivedi2
 

Similar to Deadlock Slides (20)

Unit 3 part 2(DEADLOCK)
Unit 3 part 2(DEADLOCK)Unit 3 part 2(DEADLOCK)
Unit 3 part 2(DEADLOCK)
 
Deadlock
DeadlockDeadlock
Deadlock
 
osvishal-160830131208 (1).pdf
osvishal-160830131208 (1).pdfosvishal-160830131208 (1).pdf
osvishal-160830131208 (1).pdf
 
Deadlock
DeadlockDeadlock
Deadlock
 
Deadlock
DeadlockDeadlock
Deadlock
 
OS Presentation 1 (1).pptx
OS Presentation 1 (1).pptxOS Presentation 1 (1).pptx
OS Presentation 1 (1).pptx
 
Os case study word
Os case study wordOs case study word
Os case study word
 
Rdbms
RdbmsRdbms
Rdbms
 
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
 
Ch 4 deadlock
Ch 4 deadlockCh 4 deadlock
Ch 4 deadlock
 
3.6 Deadlock-operating system unit 3.pptx
3.6 Deadlock-operating system unit 3.pptx3.6 Deadlock-operating system unit 3.pptx
3.6 Deadlock-operating system unit 3.pptx
 
DEADLOCK PREVENTION AND AVOIDANCE.pptx
DEADLOCK PREVENTION AND AVOIDANCE.pptxDEADLOCK PREVENTION AND AVOIDANCE.pptx
DEADLOCK PREVENTION AND AVOIDANCE.pptx
 
OS 7.pptx
OS 7.pptxOS 7.pptx
OS 7.pptx
 
Deadlocks
DeadlocksDeadlocks
Deadlocks
 
operating system
operating systemoperating system
operating system
 
operating system
operating systemoperating system
operating system
 
osvzjsjjdndnnssnnsnsndndndnndeadlock.pptx
osvzjsjjdndnnssnnsnsndndndnndeadlock.pptxosvzjsjjdndnnssnnsnsndndndnndeadlock.pptx
osvzjsjjdndnnssnnsnsndndndnndeadlock.pptx
 
Deadlock in Operating System
Deadlock in Operating SystemDeadlock in Operating System
Deadlock in Operating System
 
Deadlocks Part- I.pdf
Deadlocks Part- I.pdfDeadlocks Part- I.pdf
Deadlocks Part- I.pdf
 
4.3 Deadlock [Autosaved].pptx
4.3 Deadlock [Autosaved].pptx4.3 Deadlock [Autosaved].pptx
4.3 Deadlock [Autosaved].pptx
 

Recently uploaded

Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .Satyam Kumar
 
pipeline in computer architecture design
pipeline in computer architecture  designpipeline in computer architecture  design
pipeline in computer architecture designssuser87fa0c1
 
Effects of rheological properties on mixing
Effects of rheological properties on mixingEffects of rheological properties on mixing
Effects of rheological properties on mixingviprabot1
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...asadnawaz62
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfme23b1001
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptSAURABHKUMAR892774
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxk795866
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 

Recently uploaded (20)

Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .
 
pipeline in computer architecture design
pipeline in computer architecture  designpipeline in computer architecture  design
pipeline in computer architecture design
 
Effects of rheological properties on mixing
Effects of rheological properties on mixingEffects of rheological properties on mixing
Effects of rheological properties on mixing
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
Design and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdfDesign and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdf
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdf
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.ppt
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptx
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 

Deadlock Slides

  • 2. Group Member • Sehrish Ishaq • Syed Muhammad Ali Shah • Ijlal Ahmed
  • 3. Contents: 1. Introduction 2. Strategies for handling Deadlock 3. States Of Deadlock 4. Conditions For Deadlock 5. Banking Algorithm 6. Resources Allocation Graph 7. Single And Multiple Instance
  • 4. DEADLOCK If two or more process are waiting on happening of some events, which never happens, then we say these process are involved in deadlock then that state is called Dead Lock
  • 5.
  • 6. Strategies For Handling Deadlock • Prevention • Avoidance • Detection and Recovery • Ignorance
  • 7. 1. Deadlock prevention • Deadlock happens only when Mutual Exclusion, hold and wait, No preemption and circular wait holds simultaneously. If it is possible to violate one of the four conditions at any time then the deadlock can never occur in the system. • The idea behind the approach is very simple that we have to fail one of the four conditions but there can be a big argument on its physical implementation in the system.
  • 8. 2.Deadlock Avoidance • In deadlock avoidance, the operating system checks whether the system is in safe state or in unsafe state at every step which the operating system performs. The process continues until the system is in safe state. Once the system moves to unsafe state, the OS has to backtrack one step. • In simple words, The OS reviews each allocation so that the allocation doesn't cause the deadlock in the system.
  • 9. 3.Deadlock Ignorance • Deadlock Ignorance is the most widely used approach among all the mechanism. This is being used by many operating systems mainly for end user uses. In this approach, the Operating system assumes that deadlock never occurs. It simply ignores deadlock. This approach is best suitable for a single end user system where User uses the system only for browsing and all other normal stuff.
  • 10. 4. Deadlock detection and recovery • This approach let the processes fall in deadlock and then periodically check whether deadlock occur in the system or not. If it occurs then it applies some of the recovery methods to the system to get rid of deadlock.
  • 11. States Of Deadlock  There are some techniques used to avoid deadlocks. There are two states involved in it. • Safe state • Unsafe state
  • 12. • Safe state: Safe State is when there is no chance of deadlock occurring, • Unsafe state: while unsafe state doesn't mean a deadlock has occurred yet, but means that a deadlock could happen.
  • 13. Conditions Of Deadlock • Mutual Exclusion • No preemption • Hold and Wait • Circular Wait
  • 14. Mutual Exclusion • Mutual section from the resource point of view is the fact that a resource can never be used by more than one process simultaneously which is fair enough but that is the main reason behind the deadlock.
  • 15. No Preemption • Deadlock arises due to the fact that a process can't be stopped once it starts. However, if we take the resource away from the process which is causing deadlock then we can prevent deadlock.
  • 16. Hold and Wait • Hold and wait condition lies when a process holds a resource and waiting for some other resource to complete its task. Deadlock occurs because there can be more than one process which are holding one resource and waiting for other
  • 17. Circular Wait • To violate circular wait, we can assign a priority number to each of the resource. A process can't request for a lesser priority resource. This ensures that not a single process can request a resource which is being utilized by some other process and no cycle will be formed. P1 P2 P3 R1 R2 R3
  • 18. Banking Algorithm • The banker’s algorithm is a resource allocation and deadlock avoidance algorithm that tests for safety by simulating the allocation for predetermined maximum possible amounts of all resources
  • 19. Data structures for Bank Algorithm • Available • Max • Allocation • Need
  • 20. A=10 ,B= 5,C=7 Process Allocation Max Need Available Remaining Need A B C A B C A B C A B C P1 0 1 0 7 5 3 3 3 2 7 4 3 P1 P2 2 0 0 3 2 2 5 3 2 1 2 2 P2 P3 3 0 2 9 0 2 7 4 3 6 0 0 P3 P4 2 1 1 4 2 2 7 4 5 2 1 1 P4 P5 0 0 2 5 3 3 7 5 5 5 3 1 P5 7 2 5 10 5 7
  • 21. Resource Allocation Graph 1.Single Instance 2.Multiple Instance
  • 22. Resource Allocation Graph Vertex Edge Process vertex Resource Vertex Assign Edge Request Edge Single Instance Multi Instance . . . . . . . . P P R R
  • 23. Single Instance(Deadlock Occur) Allocate Request R1 R2 R1 R2 P1 1 0 0 1 P2 0 1 1 0 R1 R2 P 1 P 2
  • 24. Single Instance(Not Deadlock Occur) Allocation Request R1 R2 R1 R2 P1 1 0 0 0 P2 0 1 0 0 P3 0 0 1 1 p1 P2 P3 R1 R2
  • 25. Multi Instance Allocate Request R1 R2 R1 R2 P1 1 0 0 1 P2 0 1 1 0 P3 0 1 0 0 .R1 P2P1 ..R2 P3