SlideShare a Scribd company logo
Operating Systems
LECTURE# 6 DEADLOCKS
1
What is dead lock
 In multiprogramming environment , several processes
compete for resources. A situation may arise where a
process is waiting for resources that is held by other
waiting processes. This situation is called a dead lock.
2
 Deadlock is defined as a situation where set of
processes are blocked because
each process holding a resource and waiting to
acquire a resource held by another process,
 A deadlock happens in operating system when two or
more processes need some resource to complete
their execution that is held by the other process.
3
Deadlock…
 Consider an example when two trains/ vehicle are coming toward
each other on same track and there is only one track, none of the
trains can move once they are in front of each other.
 Similar situation occurs in operating systems.
4
Note:
 A process in operating systems uses different resources , the resources are
used in the following way.
1) Requests a resource
2) Use the resource
2) Releases the resource
5
Dead lock Example 6
Dead lock….
 In the above diagram, the process 1 has resource 1 and needs to
acquire resource 2.
 Similarly process 2 has resource 2 and needs to acquire resource 1.
 Process 1 and process 2 are in deadlock as each of them needs the
other’s resource to complete their execution but neither of them is
willing to release their resources.
7
Deadlock Example
 One process has access to printer but is waiting for tap drive ,
while another process has access to tape drive but is waiting for
printer.
8
Resources
 A resources is an object that is used by a process. It can be a piece of hardware
such as
 Tape drive
 Printer
 Scanner
 Buffers
 Memory etc.
9
Types of Resources
1) Pre-emptible Resources :
A Pre-emptible Resource is one that can be allocated to a given process for a
period of time. Then it can be allocated to another process. Then its can reallocated
to the first process without any negative effects.
Example: memory, buffers etc.
2) Non Pre-emptible Resources :
A Non Pre-emptible Resource cannot be taken from one process and given to
another without side effects.
One example is printer. A printer cannot be taken away from one process and given
to another process in the middle of a print job.
Note: Deadlocks usually involve Non Pre-emptible Resources.
10
6.3 Deadlock Characterization
 Deadlock can arise if following four conditions take place
simultaneously in a system. (Necessary Conditions)
1) Mutual Exclusion
2) Hold and Wait
3) No Preemption
4) Circular Wait
11
Deadlock Characterization
1) Mutual Exclusion: Only one process at a time can use a
resource. If another process request that resources the
requesting process will delayed until the resource has
been released .
In the diagram below, there is a single instance of Resource
1 and it is held by Process 1 only.
12
 2) Hold and Wait: A process must be holding at least one
resource and waiting to acquire additional resources that are
concurrently being held by other processes.
 In the diagram given above, Process 2 holds Resource 2 and
Resource 3 and is requesting the Resource 1 which is held by
Process 1.
13
3) No preemption: A resource can be released only voluntarily
by the process holding it, after that process has completed its
task. OR
A resource cannot be preempted from a process by force. A
process can only release a resource voluntarily.
In the diagram, Process 2 cannot preempt Resource 1 from Process
1. It will only be released when Process 1 release it voluntarily
after its execution is complete.
14
4) 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.
15
OR
 A process is waiting for the resource held by the
second process, which is waiting for the resource
held by the third process and so on, till the last
process is waiting for a resource held by the first
process. This forms a circular chain..
16
 For example: Process 1 is allocated Resource2 and it is
requesting Resource 1. Similarly, Process 2 is allocated
Resource 1 and it is requesting Resource 2. This forms a
circular wait loop
17
Deadlock Detection
 A deadlock can be detected by a resource scheduler as it
keeps track of all the resources that are allocated to
different processes. After a deadlock is detected, it can be
resolved using the following methods
 All the processes that are involved in the deadlock are
terminated. This is not a good approach as all the progress
made by the processes is destroyed.
 Resources can be preempted from some processes and given
to others till the deadlock is resolved.
18
Method for Handling Deadlocks
1. Deadlock Prevention
2. Deadlock Avoidance
3. Deadlock Detection and Recovery
19
Deadlock Prevention
 We can prevent deadlocks by ensuring that at least one of the four
necessary conditions for deadlock cannot occur. If at least one condition is
not satisfied, a deadlock will not occur.
20
Deadlock Prevention…..
 1) Mutual Exclusion
 Mutual exclusion condition must hold for non-sharable resources.
 For example, only one process can have access to a printer at a time, otherwise
the output is disturbed.
 Some resources can be made sharable like a read-only file.
 Several processes can be granted read- only access to a file without interfering
with each other.
 However, deadlock cannot be prevented by only denying the mutual exclusion
condition because some resources are intrinsically (by birth) non-sharable.
21
Deadlock Prevention…..
 Elimination of Mutual Exclusion
 If it is shareable resource, then we can break the mutual exclusion (such as:
Read-only file)
 If it is not a shareable resource, then mutual exclusion must hold (such as:
Printer) because non shareable means that their states cannot be saved and
restored without ill effects.
22
Deadlock Prevention…..
2) Elimination of Hold and wait: two methods
 A) Require process to request and be allocated all its resources before it begins
execution.
 B) Allow process to request resources only when the process has none.
 Example:
 We consider a process that copies data from DVD drive to a picture file on disk
and then prints the picture to a printer
 Method 1: Request DVD drive, Disk, and Printer before it execute. It will hold
the Printer for entire execution, even though it needs the printer only at the end.
 Method2: Request only for DVD drive and Disk initially. It finishes the copy step
and releases both resources. The process must then again ask for disk and printer
To finish the job.
23
Deadlock Prevention…..
 3) Elimination of No preemption:
 a) Release any resource already being held if the process can't get an
additional resource.
 b) Allow preemption - if a needed resource is held by another process,
which is also waiting on some resource, steal it. Otherwise wait.
 c) Process will be restarted only when it can regain its old Resources, as
well as the new ones that it is requesting.
24
Deadlock Prevention…..
4) Elimination of Circular wait
 Each resource will be assigned with a numerical number. A process
can request the resources only in increasing order of numbering.
For Example,
 if P1 process is allocated R5 resources, now next time if P1 ask for
R4, R3 lesser than R5 such request will not be granted, only request
for resources more than R5 will be granted.
25
Deadlock Avoidance
 Deadlock avoidance can be done with help of Banker’s Algorithm.
 Banker’s Algorithm:
 Bankers' Algorithm is resource allocation and deadlock avoidance
algorithm which test all the request made by processes for resources,
it checks for the safe state, if after granting request system remains
in the safe state it allows the request and if there is no safe state it
doesn’t allow the request made by the process.
26
Safe State and Unsafe State
 A state is said to be a safe state if the system may allocate
the required resources to each process up to the maximum
required in a particular sequence without facing deadlock.
 In safe state , deadlock cannot occur.
 If a deadlock is possible the system is said to be in an
unsafe state.
 The idea of avoiding a deadlock is to simply not allow the
system to enter an unsafe state that may cause a deadlock
27
Inputs to Banker’s Algorithm:
1) Max need of resources by each process.
2) Currently allocated resources by each
process.
3) Max free available resources in the
system.
28
Banker’s Algorithm step….
 Need is less than or equal to work then
 Work= work + allocation
29
6.4.3 Deadlock Detection and Recovery 30
Deadlock Detection and Recovery… 31
32

More Related Content

What's hot

Dead Lock in operating system
Dead Lock in operating systemDead Lock in operating system
Dead Lock in operating system
Ali Haider
 
Introduction to Database Management Systems
Introduction to Database Management SystemsIntroduction to Database Management Systems
Introduction to Database Management Systems
Adri Jovin
 
deadlock handling
deadlock handlingdeadlock handling
deadlock handling
Suraj Kumar
 
Operating system - Deadlock
Operating system - DeadlockOperating system - Deadlock
Operating system - Deadlock
Shashank Yenurkar
 
concurrency-control
concurrency-controlconcurrency-control
concurrency-control
Saranya Natarajan
 
DeadLock in Operating-Systems
DeadLock in Operating-SystemsDeadLock in Operating-Systems
DeadLock in Operating-Systems
Venkata Sreeram
 
Process synchronization in Operating Systems
Process synchronization in Operating SystemsProcess synchronization in Operating Systems
Process synchronization in Operating Systems
Ritu Ranjan Shrivastwa
 
Distributed DBMS - Unit 9 - Distributed Deadlock & Recovery
Distributed DBMS - Unit 9 - Distributed Deadlock & RecoveryDistributed DBMS - Unit 9 - Distributed Deadlock & Recovery
Distributed DBMS - Unit 9 - Distributed Deadlock & Recovery
Gyanmanjari Institute Of Technology
 
Transaction Processing in DBMS.pptx
Transaction Processing in DBMS.pptxTransaction Processing in DBMS.pptx
Transaction Processing in DBMS.pptx
Lovely Professional University
 
Memory management ppt
Memory management pptMemory management ppt
Memory management ppt
ManishaJha43
 
Deadlock
DeadlockDeadlock
Deadlock
Sajan Sahu
 
database recovery techniques
database recovery techniques database recovery techniques
database recovery techniques Kalhan Liyanage
 
Deadlock Presentation
Deadlock PresentationDeadlock Presentation
Deadlock Presentation
salmancreation
 
Deadlock detection & prevention
Deadlock detection & preventionDeadlock detection & prevention
Deadlock detection & prevention
IkhtiarUddinShaHin
 
Deadlock in Operating System
Deadlock in Operating SystemDeadlock in Operating System
Deadlock in Operating System
AUST
 
Scheduling algorithms
Scheduling algorithmsScheduling algorithms
Scheduling algorithms
Chankey Pathak
 
process management
 process management process management
process managementAshish Kumar
 
Deadlock avoidance (Safe State, Resource Allocation Graph Algorithm)
Deadlock avoidance (Safe State, Resource Allocation Graph Algorithm)Deadlock avoidance (Safe State, Resource Allocation Graph Algorithm)
Deadlock avoidance (Safe State, Resource Allocation Graph Algorithm)
Shayek Parvez
 

What's hot (20)

Dead Lock in operating system
Dead Lock in operating systemDead Lock in operating system
Dead Lock in operating system
 
Introduction to Database Management Systems
Introduction to Database Management SystemsIntroduction to Database Management Systems
Introduction to Database Management Systems
 
Deadlock ppt
Deadlock ppt Deadlock ppt
Deadlock ppt
 
deadlock handling
deadlock handlingdeadlock handling
deadlock handling
 
Operating system - Deadlock
Operating system - DeadlockOperating system - Deadlock
Operating system - Deadlock
 
concurrency-control
concurrency-controlconcurrency-control
concurrency-control
 
DeadLock in Operating-Systems
DeadLock in Operating-SystemsDeadLock in Operating-Systems
DeadLock in Operating-Systems
 
Process synchronization in Operating Systems
Process synchronization in Operating SystemsProcess synchronization in Operating Systems
Process synchronization in Operating Systems
 
Distributed DBMS - Unit 9 - Distributed Deadlock & Recovery
Distributed DBMS - Unit 9 - Distributed Deadlock & RecoveryDistributed DBMS - Unit 9 - Distributed Deadlock & Recovery
Distributed DBMS - Unit 9 - Distributed Deadlock & Recovery
 
Mutual exclusion and sync
Mutual exclusion and syncMutual exclusion and sync
Mutual exclusion and sync
 
Transaction Processing in DBMS.pptx
Transaction Processing in DBMS.pptxTransaction Processing in DBMS.pptx
Transaction Processing in DBMS.pptx
 
Memory management ppt
Memory management pptMemory management ppt
Memory management ppt
 
Deadlock
DeadlockDeadlock
Deadlock
 
database recovery techniques
database recovery techniques database recovery techniques
database recovery techniques
 
Deadlock Presentation
Deadlock PresentationDeadlock Presentation
Deadlock Presentation
 
Deadlock detection & prevention
Deadlock detection & preventionDeadlock detection & prevention
Deadlock detection & prevention
 
Deadlock in Operating System
Deadlock in Operating SystemDeadlock in Operating System
Deadlock in Operating System
 
Scheduling algorithms
Scheduling algorithmsScheduling algorithms
Scheduling algorithms
 
process management
 process management process management
process management
 
Deadlock avoidance (Safe State, Resource Allocation Graph Algorithm)
Deadlock avoidance (Safe State, Resource Allocation Graph Algorithm)Deadlock avoidance (Safe State, Resource Allocation Graph Algorithm)
Deadlock avoidance (Safe State, Resource Allocation Graph Algorithm)
 

Similar to Operating system Deadlock

4.3 Deadlock [Autosaved].pptx
4.3 Deadlock [Autosaved].pptx4.3 Deadlock [Autosaved].pptx
4.3 Deadlock [Autosaved].pptx
DishaDwivedi2
 
Ch 4 deadlock
Ch 4 deadlockCh 4 deadlock
Ch 4 deadlock
madhuributani
 
Deadlocks
DeadlocksDeadlocks
Deadlock- Operating System
Deadlock- Operating SystemDeadlock- Operating System
Deadlock- Operating System
Rajan Shah
 
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
svulasal
 
Os case study word
Os case study wordOs case study word
Os case study word
Dhol Yash
 
Unit iv: Deadlocks
Unit iv: DeadlocksUnit iv: Deadlocks
Unit iv: Deadlocks
Arnav Chowdhury
 
3 (1) [Autosaved].ppt
3 (1) [Autosaved].ppt3 (1) [Autosaved].ppt
3 (1) [Autosaved].ppt
amadayshwan
 
Deadlock and memory management -- Operating System
Deadlock and memory management -- Operating SystemDeadlock and memory management -- Operating System
Deadlock and memory management -- Operating System
EktaVaswani2
 
Deadlockproj.pptx
Deadlockproj.pptxDeadlockproj.pptx
Deadlockproj.pptx
sonu642319
 
Unit 3 part 2(DEADLOCK)
Unit 3 part 2(DEADLOCK)Unit 3 part 2(DEADLOCK)
Unit 3 part 2(DEADLOCK)
WajeehaBaig
 
Deadlocks
DeadlocksDeadlocks
Deadlocks
Zahid Ali
 
Module3
Module3Module3
Module3
dilshad begum
 
Deadlocks
DeadlocksDeadlocks
Deadlocks
Dilum Bandara
 
Deadlocks by wani zahoor
Deadlocks by wani zahoorDeadlocks by wani zahoor
Deadlocks by wani zahoor
Wani Zahoor
 
Deadlocks 160928121516-160928183232
Deadlocks 160928121516-160928183232Deadlocks 160928121516-160928183232
Deadlocks 160928121516-160928183232
marangburu42
 
9 deadlock
9 deadlock9 deadlock
9 deadlock
GRajendra
 

Similar to Operating system Deadlock (20)

4.3 Deadlock [Autosaved].pptx
4.3 Deadlock [Autosaved].pptx4.3 Deadlock [Autosaved].pptx
4.3 Deadlock [Autosaved].pptx
 
Ch 4 deadlock
Ch 4 deadlockCh 4 deadlock
Ch 4 deadlock
 
Deadlocks
DeadlocksDeadlocks
Deadlocks
 
Deadlock- Operating System
Deadlock- Operating SystemDeadlock- Operating System
Deadlock- Operating System
 
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
 
Os case study word
Os case study wordOs case study word
Os case study word
 
Distributed deadlock
Distributed deadlockDistributed deadlock
Distributed deadlock
 
Unit iv: Deadlocks
Unit iv: DeadlocksUnit iv: Deadlocks
Unit iv: Deadlocks
 
3 (1) [Autosaved].ppt
3 (1) [Autosaved].ppt3 (1) [Autosaved].ppt
3 (1) [Autosaved].ppt
 
Os module 2 d
Os module 2 dOs module 2 d
Os module 2 d
 
Deadlock and memory management -- Operating System
Deadlock and memory management -- Operating SystemDeadlock and memory management -- Operating System
Deadlock and memory management -- Operating System
 
Deadlockproj.pptx
Deadlockproj.pptxDeadlockproj.pptx
Deadlockproj.pptx
 
Unit 3 part 2(DEADLOCK)
Unit 3 part 2(DEADLOCK)Unit 3 part 2(DEADLOCK)
Unit 3 part 2(DEADLOCK)
 
ikh311-05
ikh311-05ikh311-05
ikh311-05
 
Deadlocks
DeadlocksDeadlocks
Deadlocks
 
Module3
Module3Module3
Module3
 
Deadlocks
DeadlocksDeadlocks
Deadlocks
 
Deadlocks by wani zahoor
Deadlocks by wani zahoorDeadlocks by wani zahoor
Deadlocks by wani zahoor
 
Deadlocks 160928121516-160928183232
Deadlocks 160928121516-160928183232Deadlocks 160928121516-160928183232
Deadlocks 160928121516-160928183232
 
9 deadlock
9 deadlock9 deadlock
9 deadlock
 

Recently uploaded

Gregory Harris' Civics Presentation.pptx
Gregory Harris' Civics Presentation.pptxGregory Harris' Civics Presentation.pptx
Gregory Harris' Civics Presentation.pptx
gharris9
 
somanykidsbutsofewfathers-140705000023-phpapp02.pptx
somanykidsbutsofewfathers-140705000023-phpapp02.pptxsomanykidsbutsofewfathers-140705000023-phpapp02.pptx
somanykidsbutsofewfathers-140705000023-phpapp02.pptx
Howard Spence
 
International Workshop on Artificial Intelligence in Software Testing
International Workshop on Artificial Intelligence in Software TestingInternational Workshop on Artificial Intelligence in Software Testing
International Workshop on Artificial Intelligence in Software Testing
Sebastiano Panichella
 
Obesity causes and management and associated medical conditions
Obesity causes and management and associated medical conditionsObesity causes and management and associated medical conditions
Obesity causes and management and associated medical conditions
Faculty of Medicine And Health Sciences
 
Doctoral Symposium at the 17th IEEE International Conference on Software Test...
Doctoral Symposium at the 17th IEEE International Conference on Software Test...Doctoral Symposium at the 17th IEEE International Conference on Software Test...
Doctoral Symposium at the 17th IEEE International Conference on Software Test...
Sebastiano Panichella
 
Burning Issue Presentation By Kenmaryon.pdf
Burning Issue Presentation By Kenmaryon.pdfBurning Issue Presentation By Kenmaryon.pdf
Burning Issue Presentation By Kenmaryon.pdf
kkirkland2
 
0x01 - Newton's Third Law: Static vs. Dynamic Abusers
0x01 - Newton's Third Law:  Static vs. Dynamic Abusers0x01 - Newton's Third Law:  Static vs. Dynamic Abusers
0x01 - Newton's Third Law: Static vs. Dynamic Abusers
OWASP Beja
 
Announcement of 18th IEEE International Conference on Software Testing, Verif...
Announcement of 18th IEEE International Conference on Software Testing, Verif...Announcement of 18th IEEE International Conference on Software Testing, Verif...
Announcement of 18th IEEE International Conference on Software Testing, Verif...
Sebastiano Panichella
 
Bitcoin Lightning wallet and tic-tac-toe game XOXO
Bitcoin Lightning wallet and tic-tac-toe game XOXOBitcoin Lightning wallet and tic-tac-toe game XOXO
Bitcoin Lightning wallet and tic-tac-toe game XOXO
Matjaž Lipuš
 
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdfBonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
khadija278284
 
Presentatie 4. Jochen Cremer - TU Delft 28 mei 2024
Presentatie 4. Jochen Cremer - TU Delft 28 mei 2024Presentatie 4. Jochen Cremer - TU Delft 28 mei 2024
Presentatie 4. Jochen Cremer - TU Delft 28 mei 2024
Dutch Power
 
Supercharge your AI - SSP Industry Breakout Session 2024-v2_1.pdf
Supercharge your AI - SSP Industry Breakout Session 2024-v2_1.pdfSupercharge your AI - SSP Industry Breakout Session 2024-v2_1.pdf
Supercharge your AI - SSP Industry Breakout Session 2024-v2_1.pdf
Access Innovations, Inc.
 
Media as a Mind Controlling Strategy In Old and Modern Era
Media as a Mind Controlling Strategy In Old and Modern EraMedia as a Mind Controlling Strategy In Old and Modern Era
Media as a Mind Controlling Strategy In Old and Modern Era
faizulhassanfaiz1670
 
Competition and Regulation in Professional Services – KLEINER – June 2024 OEC...
Competition and Regulation in Professional Services – KLEINER – June 2024 OEC...Competition and Regulation in Professional Services – KLEINER – June 2024 OEC...
Competition and Regulation in Professional Services – KLEINER – June 2024 OEC...
OECD Directorate for Financial and Enterprise Affairs
 
María Carolina Martínez - eCommerce Day Colombia 2024
María Carolina Martínez - eCommerce Day Colombia 2024María Carolina Martínez - eCommerce Day Colombia 2024
María Carolina Martínez - eCommerce Day Colombia 2024
eCommerce Institute
 
Getting started with Amazon Bedrock Studio and Control Tower
Getting started with Amazon Bedrock Studio and Control TowerGetting started with Amazon Bedrock Studio and Control Tower
Getting started with Amazon Bedrock Studio and Control Tower
Vladimir Samoylov
 
Presentatie 8. Joost van der Linde & Daniel Anderton - Eliq 28 mei 2024
Presentatie 8. Joost van der Linde & Daniel Anderton - Eliq 28 mei 2024Presentatie 8. Joost van der Linde & Daniel Anderton - Eliq 28 mei 2024
Presentatie 8. Joost van der Linde & Daniel Anderton - Eliq 28 mei 2024
Dutch Power
 
Tom tresser burning issue.pptx My Burning issue
Tom tresser burning issue.pptx My Burning issueTom tresser burning issue.pptx My Burning issue
Tom tresser burning issue.pptx My Burning issue
amekonnen
 
AWANG ANIQKMALBIN AWANG TAJUDIN B22080004 ASSIGNMENT 2 MPU3193 PHILOSOPHY AND...
AWANG ANIQKMALBIN AWANG TAJUDIN B22080004 ASSIGNMENT 2 MPU3193 PHILOSOPHY AND...AWANG ANIQKMALBIN AWANG TAJUDIN B22080004 ASSIGNMENT 2 MPU3193 PHILOSOPHY AND...
AWANG ANIQKMALBIN AWANG TAJUDIN B22080004 ASSIGNMENT 2 MPU3193 PHILOSOPHY AND...
AwangAniqkmals
 
Acorn Recovery: Restore IT infra within minutes
Acorn Recovery: Restore IT infra within minutesAcorn Recovery: Restore IT infra within minutes
Acorn Recovery: Restore IT infra within minutes
IP ServerOne
 

Recently uploaded (20)

Gregory Harris' Civics Presentation.pptx
Gregory Harris' Civics Presentation.pptxGregory Harris' Civics Presentation.pptx
Gregory Harris' Civics Presentation.pptx
 
somanykidsbutsofewfathers-140705000023-phpapp02.pptx
somanykidsbutsofewfathers-140705000023-phpapp02.pptxsomanykidsbutsofewfathers-140705000023-phpapp02.pptx
somanykidsbutsofewfathers-140705000023-phpapp02.pptx
 
International Workshop on Artificial Intelligence in Software Testing
International Workshop on Artificial Intelligence in Software TestingInternational Workshop on Artificial Intelligence in Software Testing
International Workshop on Artificial Intelligence in Software Testing
 
Obesity causes and management and associated medical conditions
Obesity causes and management and associated medical conditionsObesity causes and management and associated medical conditions
Obesity causes and management and associated medical conditions
 
Doctoral Symposium at the 17th IEEE International Conference on Software Test...
Doctoral Symposium at the 17th IEEE International Conference on Software Test...Doctoral Symposium at the 17th IEEE International Conference on Software Test...
Doctoral Symposium at the 17th IEEE International Conference on Software Test...
 
Burning Issue Presentation By Kenmaryon.pdf
Burning Issue Presentation By Kenmaryon.pdfBurning Issue Presentation By Kenmaryon.pdf
Burning Issue Presentation By Kenmaryon.pdf
 
0x01 - Newton's Third Law: Static vs. Dynamic Abusers
0x01 - Newton's Third Law:  Static vs. Dynamic Abusers0x01 - Newton's Third Law:  Static vs. Dynamic Abusers
0x01 - Newton's Third Law: Static vs. Dynamic Abusers
 
Announcement of 18th IEEE International Conference on Software Testing, Verif...
Announcement of 18th IEEE International Conference on Software Testing, Verif...Announcement of 18th IEEE International Conference on Software Testing, Verif...
Announcement of 18th IEEE International Conference on Software Testing, Verif...
 
Bitcoin Lightning wallet and tic-tac-toe game XOXO
Bitcoin Lightning wallet and tic-tac-toe game XOXOBitcoin Lightning wallet and tic-tac-toe game XOXO
Bitcoin Lightning wallet and tic-tac-toe game XOXO
 
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdfBonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
 
Presentatie 4. Jochen Cremer - TU Delft 28 mei 2024
Presentatie 4. Jochen Cremer - TU Delft 28 mei 2024Presentatie 4. Jochen Cremer - TU Delft 28 mei 2024
Presentatie 4. Jochen Cremer - TU Delft 28 mei 2024
 
Supercharge your AI - SSP Industry Breakout Session 2024-v2_1.pdf
Supercharge your AI - SSP Industry Breakout Session 2024-v2_1.pdfSupercharge your AI - SSP Industry Breakout Session 2024-v2_1.pdf
Supercharge your AI - SSP Industry Breakout Session 2024-v2_1.pdf
 
Media as a Mind Controlling Strategy In Old and Modern Era
Media as a Mind Controlling Strategy In Old and Modern EraMedia as a Mind Controlling Strategy In Old and Modern Era
Media as a Mind Controlling Strategy In Old and Modern Era
 
Competition and Regulation in Professional Services – KLEINER – June 2024 OEC...
Competition and Regulation in Professional Services – KLEINER – June 2024 OEC...Competition and Regulation in Professional Services – KLEINER – June 2024 OEC...
Competition and Regulation in Professional Services – KLEINER – June 2024 OEC...
 
María Carolina Martínez - eCommerce Day Colombia 2024
María Carolina Martínez - eCommerce Day Colombia 2024María Carolina Martínez - eCommerce Day Colombia 2024
María Carolina Martínez - eCommerce Day Colombia 2024
 
Getting started with Amazon Bedrock Studio and Control Tower
Getting started with Amazon Bedrock Studio and Control TowerGetting started with Amazon Bedrock Studio and Control Tower
Getting started with Amazon Bedrock Studio and Control Tower
 
Presentatie 8. Joost van der Linde & Daniel Anderton - Eliq 28 mei 2024
Presentatie 8. Joost van der Linde & Daniel Anderton - Eliq 28 mei 2024Presentatie 8. Joost van der Linde & Daniel Anderton - Eliq 28 mei 2024
Presentatie 8. Joost van der Linde & Daniel Anderton - Eliq 28 mei 2024
 
Tom tresser burning issue.pptx My Burning issue
Tom tresser burning issue.pptx My Burning issueTom tresser burning issue.pptx My Burning issue
Tom tresser burning issue.pptx My Burning issue
 
AWANG ANIQKMALBIN AWANG TAJUDIN B22080004 ASSIGNMENT 2 MPU3193 PHILOSOPHY AND...
AWANG ANIQKMALBIN AWANG TAJUDIN B22080004 ASSIGNMENT 2 MPU3193 PHILOSOPHY AND...AWANG ANIQKMALBIN AWANG TAJUDIN B22080004 ASSIGNMENT 2 MPU3193 PHILOSOPHY AND...
AWANG ANIQKMALBIN AWANG TAJUDIN B22080004 ASSIGNMENT 2 MPU3193 PHILOSOPHY AND...
 
Acorn Recovery: Restore IT infra within minutes
Acorn Recovery: Restore IT infra within minutesAcorn Recovery: Restore IT infra within minutes
Acorn Recovery: Restore IT infra within minutes
 

Operating system Deadlock

  • 2. What is dead lock  In multiprogramming environment , several processes compete for resources. A situation may arise where a process is waiting for resources that is held by other waiting processes. This situation is called a dead lock. 2
  • 3.  Deadlock is defined as a situation where set of processes are blocked because each process holding a resource and waiting to acquire a resource held by another process,  A deadlock happens in operating system when two or more processes need some resource to complete their execution that is held by the other process. 3
  • 4. Deadlock…  Consider an example when two trains/ vehicle are coming toward each other on same track and there is only one track, none of the trains can move once they are in front of each other.  Similar situation occurs in operating systems. 4
  • 5. Note:  A process in operating systems uses different resources , the resources are used in the following way. 1) Requests a resource 2) Use the resource 2) Releases the resource 5
  • 7. Dead lock….  In the above diagram, the process 1 has resource 1 and needs to acquire resource 2.  Similarly process 2 has resource 2 and needs to acquire resource 1.  Process 1 and process 2 are in deadlock as each of them needs the other’s resource to complete their execution but neither of them is willing to release their resources. 7
  • 8. Deadlock Example  One process has access to printer but is waiting for tap drive , while another process has access to tape drive but is waiting for printer. 8
  • 9. Resources  A resources is an object that is used by a process. It can be a piece of hardware such as  Tape drive  Printer  Scanner  Buffers  Memory etc. 9
  • 10. Types of Resources 1) Pre-emptible Resources : A Pre-emptible Resource is one that can be allocated to a given process for a period of time. Then it can be allocated to another process. Then its can reallocated to the first process without any negative effects. Example: memory, buffers etc. 2) Non Pre-emptible Resources : A Non Pre-emptible Resource cannot be taken from one process and given to another without side effects. One example is printer. A printer cannot be taken away from one process and given to another process in the middle of a print job. Note: Deadlocks usually involve Non Pre-emptible Resources. 10
  • 11. 6.3 Deadlock Characterization  Deadlock can arise if following four conditions take place simultaneously in a system. (Necessary Conditions) 1) Mutual Exclusion 2) Hold and Wait 3) No Preemption 4) Circular Wait 11
  • 12. Deadlock Characterization 1) Mutual Exclusion: Only one process at a time can use a resource. If another process request that resources the requesting process will delayed until the resource has been released . In the diagram below, there is a single instance of Resource 1 and it is held by Process 1 only. 12
  • 13.  2) Hold and Wait: A process must be holding at least one resource and waiting to acquire additional resources that are concurrently being held by other processes.  In the diagram given above, Process 2 holds Resource 2 and Resource 3 and is requesting the Resource 1 which is held by Process 1. 13
  • 14. 3) No preemption: A resource can be released only voluntarily by the process holding it, after that process has completed its task. OR A resource cannot be preempted from a process by force. A process can only release a resource voluntarily. In the diagram, Process 2 cannot preempt Resource 1 from Process 1. It will only be released when Process 1 release it voluntarily after its execution is complete. 14
  • 15. 4) 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. 15
  • 16. OR  A process is waiting for the resource held by the second process, which is waiting for the resource held by the third process and so on, till the last process is waiting for a resource held by the first process. This forms a circular chain.. 16
  • 17.  For example: Process 1 is allocated Resource2 and it is requesting Resource 1. Similarly, Process 2 is allocated Resource 1 and it is requesting Resource 2. This forms a circular wait loop 17
  • 18. Deadlock Detection  A deadlock can be detected by a resource scheduler as it keeps track of all the resources that are allocated to different processes. After a deadlock is detected, it can be resolved using the following methods  All the processes that are involved in the deadlock are terminated. This is not a good approach as all the progress made by the processes is destroyed.  Resources can be preempted from some processes and given to others till the deadlock is resolved. 18
  • 19. Method for Handling Deadlocks 1. Deadlock Prevention 2. Deadlock Avoidance 3. Deadlock Detection and Recovery 19
  • 20. Deadlock Prevention  We can prevent deadlocks by ensuring that at least one of the four necessary conditions for deadlock cannot occur. If at least one condition is not satisfied, a deadlock will not occur. 20
  • 21. Deadlock Prevention…..  1) Mutual Exclusion  Mutual exclusion condition must hold for non-sharable resources.  For example, only one process can have access to a printer at a time, otherwise the output is disturbed.  Some resources can be made sharable like a read-only file.  Several processes can be granted read- only access to a file without interfering with each other.  However, deadlock cannot be prevented by only denying the mutual exclusion condition because some resources are intrinsically (by birth) non-sharable. 21
  • 22. Deadlock Prevention…..  Elimination of Mutual Exclusion  If it is shareable resource, then we can break the mutual exclusion (such as: Read-only file)  If it is not a shareable resource, then mutual exclusion must hold (such as: Printer) because non shareable means that their states cannot be saved and restored without ill effects. 22
  • 23. Deadlock Prevention….. 2) Elimination of Hold and wait: two methods  A) Require process to request and be allocated all its resources before it begins execution.  B) Allow process to request resources only when the process has none.  Example:  We consider a process that copies data from DVD drive to a picture file on disk and then prints the picture to a printer  Method 1: Request DVD drive, Disk, and Printer before it execute. It will hold the Printer for entire execution, even though it needs the printer only at the end.  Method2: Request only for DVD drive and Disk initially. It finishes the copy step and releases both resources. The process must then again ask for disk and printer To finish the job. 23
  • 24. Deadlock Prevention…..  3) Elimination of No preemption:  a) Release any resource already being held if the process can't get an additional resource.  b) Allow preemption - if a needed resource is held by another process, which is also waiting on some resource, steal it. Otherwise wait.  c) Process will be restarted only when it can regain its old Resources, as well as the new ones that it is requesting. 24
  • 25. Deadlock Prevention….. 4) Elimination of Circular wait  Each resource will be assigned with a numerical number. A process can request the resources only in increasing order of numbering. For Example,  if P1 process is allocated R5 resources, now next time if P1 ask for R4, R3 lesser than R5 such request will not be granted, only request for resources more than R5 will be granted. 25
  • 26. Deadlock Avoidance  Deadlock avoidance can be done with help of Banker’s Algorithm.  Banker’s Algorithm:  Bankers' Algorithm is resource allocation and deadlock avoidance algorithm which test all the request made by processes for resources, it checks for the safe state, if after granting request system remains in the safe state it allows the request and if there is no safe state it doesn’t allow the request made by the process. 26
  • 27. Safe State and Unsafe State  A state is said to be a safe state if the system may allocate the required resources to each process up to the maximum required in a particular sequence without facing deadlock.  In safe state , deadlock cannot occur.  If a deadlock is possible the system is said to be in an unsafe state.  The idea of avoiding a deadlock is to simply not allow the system to enter an unsafe state that may cause a deadlock 27
  • 28. Inputs to Banker’s Algorithm: 1) Max need of resources by each process. 2) Currently allocated resources by each process. 3) Max free available resources in the system. 28
  • 29. Banker’s Algorithm step….  Need is less than or equal to work then  Work= work + allocation 29
  • 30. 6.4.3 Deadlock Detection and Recovery 30
  • 31. Deadlock Detection and Recovery… 31
  • 32. 32

Editor's Notes

  1. 1