SlideShare a Scribd company logo
1 of 14
Download to read offline
Unit 3 – Part 2
Deadlock
Methods for handling deadlock
There are three ways to handle deadlock
1) Deadlock prevention or avoidance:
The idea is to not let the system into deadlock state.
One can zoom into each category individually, Prevention
is done by negating one of above mentioned necessary
conditions for deadlock.
Avoidance is kind of futuristic in nature. By using strategy
of “Avoidance”, we have to make an assumption. We need
to ensure that all information about resources which
process WILL need are known to us prior to execution of
the process.
2) Deadlock detection and recovery: Let deadlock occur,
then do preemption to handle it once occurred.
3) Ignore the problem all together: If deadlock is very
rare, then let it happen and reboot the system. This is the
approach that both Windows and UNIX take.
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.
If resources have single instance:
In this case for Deadlock detection we can run an algorithm to
check for cycle in the Resource Allocation Graph. Presence of
cycle in the graph is the sufficient condition for deadlock.
In the diagram, resource 1 and resource 2 have single instances.
There is a cycle R1 → P1 → R2 → P2. So, Deadlock is Confirmed.
Deadlock Detection
If there are multiple instances of resources:
Detection of the cycle is necessary but not sufficient
condition for deadlock detection, in this case, the
system may or may not be in deadlock varies
according to different situations.
Deadlock Recovery
A traditional operating system such as Windows doesn’t deal
with deadlock recovery as it is time and space consuming
process. Real-time operating systems use Deadlock recovery.
Recovery method
Killing the process: killing all the process involved in the
deadlock. Killing process one by one. After killing each process
check for deadlock again keep repeating the process till
system recover from deadlock.
Resource Preemption: Resources are preempted from the
processes involved in the deadlock, preempted resources are
allocated to other processes so that there is a possibility of
recovering the system from deadlock. In this case, the system
goes into starvation.
Deadlock Avoidance
Deadlock avoidance merely works to avoid deadlock; it does not totally
prevent it. The basic idea here is to allocate resources only if the resulting
global state is a safe state.
In other words, unsafe states are avoided, meaning that deadlock is avoided
as well.
• When a process requests a resource, even if it is available, it is not
immediately allocated to the process. Instead the
systems assumes (pretends) it is so allocated.
• With this assumption, along with advance knowledge of all the resources
needed for all the processes, the system performs some analysis to
decide whether or not granting the request is safe.
• If the request is safe, the resource is granted to the requesting process.
Otherwise, the resource is not given to the process at this time.
This type of algorithm requires each site to have access to a global state
(requiring too much storage and communication). Also the checking of the
involved data structures must be done in a mutually exclusive fashion. With
many sites and resources, it just takes too long.
Deadlock avoidance can be done with Banker’s Algorithm.
Banker’s Algorithm
Bankers’s 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.
Inputs to Banker’s Algorithm:
• Max need of resources by each process.
• Currently allocated resources by each process.
• Max free available resources in the system.
The request will only be granted under the below condition:
• If the request made by the process is less than equal to max need to that
process.
• If the request made by the process is less than equal to the freely
available resource in the system.
Deadlock Prevention
It is very important to prevent a deadlock before it
can occur. So, the system checks each transaction
before it is executed to make sure it does not lead to
deadlock. If there is even a slight chance that a
transaction may lead to deadlock in the future, it is
never allowed to execute
Deadlock Prevention
This strategy involves designing a system that
violates one of the four necessary conditions
required for the occurrence of deadlock.
This ensures that the system remains free from the
deadlock.
The various conditions of deadlock occurrence may
be violated as-
• Eliminate Mutual Exclusion
• Eliminate Hold and Wait
• Eliminate No Pre-emption
• Eliminate Circular Wait
Deadlock Prevention
1- Eliminate Mutual Exclusion
To violate this condition, all the system resources
must be such that they can be used in a shareable
mode.
In a system, there are always some resources which
are mutually exclusive by nature.
So, this condition can not be violated.
Deadlock Prevention
2- Eliminate Hold and Wait
This condition can be violated in the following ways-
Approach-01:
In this approach,
• A process has to first request for all the resources it requires for
execution.
• Once it has acquired all the resources, only then it can start its execution.
• This approach ensures that the process does not hold some resources and
wait for other resources.
Drawbacks-
The drawbacks of this approach are-
• It is less efficient.
• It is not implementable since it is not possible to predict in advance which
resources will be required during execution.
Deadlock Prevention
Approach-02:
In this approach,
• A process is allowed to acquire the resources it desires at the
current moment.
• After acquiring the resources, it start its execution.
• Now before making any new request, it has to compulsorily
release all the resources that it holds currently.
• This approach is efficient and implementable.
Approach-03:
In this approach,
• A timer is set after the process acquires any resource.
• After the timer expires, a process has to compulsorily release the
resource.
Deadlock Prevention
3-Eliminate No Pre-emption
This condition can by violated by forceful pre-emption.
• Consider a process is holding some resources and
request other resources that can not be immediately
allocated to it.
• Then, by forcefully pre-empting the currently held
resources, the condition can be violated.
• A process is allowed to forcefully pre-empt the
resources possessed by some other process only if It is
a high priority process or a system process. The victim
process is in the waiting state.
Deadlock Prevention
4-Eliminate Circular Wait
This condition can be violated by not allowing the processes to wait for
resources in a cyclic manner.
To violate this condition, the following approach is followed-
Approach
A numerical number is assigned to every resource.
Each process is allowed to request for the resources either in only
increasing or only decreasing order of the resource number.
In case increasing order is followed, if a process requires a lesser number
resource, then it must release all the resources having larger number and
vice versa.
This approach is the most practical approach and implementable.
However, this approach may cause starvation but will never lead to
deadlock.

More Related Content

What's hot (20)

Deadlocks
DeadlocksDeadlocks
Deadlocks
 
Operating system Deadlock
Operating system DeadlockOperating system Deadlock
Operating system Deadlock
 
Distributed deadlock
Distributed deadlockDistributed deadlock
Distributed deadlock
 
Deadlocks
DeadlocksDeadlocks
Deadlocks
 
deadlock prevention
deadlock preventiondeadlock prevention
deadlock prevention
 
Methods for handling deadlocks
Methods for handling deadlocksMethods for handling deadlocks
Methods for handling deadlocks
 
Operating system - Deadlock
Operating system - DeadlockOperating system - Deadlock
Operating system - Deadlock
 
Deadlock- Operating System
Deadlock- Operating SystemDeadlock- Operating System
Deadlock- Operating System
 
Deadlock
DeadlockDeadlock
Deadlock
 
Deadlock
DeadlockDeadlock
Deadlock
 
Deadlock Avoidance in Operating System
Deadlock Avoidance in Operating SystemDeadlock Avoidance in Operating System
Deadlock Avoidance in Operating System
 
ikh311-05
ikh311-05ikh311-05
ikh311-05
 
Deadlock
DeadlockDeadlock
Deadlock
 
DeadLock in Operating-Systems
DeadLock in Operating-SystemsDeadLock in Operating-Systems
DeadLock in Operating-Systems
 
Deadlock and memory management -- Operating System
Deadlock and memory management -- Operating SystemDeadlock and memory management -- Operating System
Deadlock and memory management -- Operating System
 
Deadlock in Operating System
Deadlock in Operating SystemDeadlock in Operating System
Deadlock in Operating System
 
Deadlocks
DeadlocksDeadlocks
Deadlocks
 
Deadlock Presentation
Deadlock PresentationDeadlock Presentation
Deadlock Presentation
 
Deadlock ppt
Deadlock ppt Deadlock ppt
Deadlock ppt
 
Chapter06
Chapter06Chapter06
Chapter06
 

Similar to Unit 3 part 2(DEADLOCK)

4.3 Deadlock [Autosaved].pptx
4.3 Deadlock [Autosaved].pptx4.3 Deadlock [Autosaved].pptx
4.3 Deadlock [Autosaved].pptxDishaDwivedi2
 
DEADLOCK PREVENTION AND AVOIDANCE.pptx
DEADLOCK PREVENTION AND AVOIDANCE.pptxDEADLOCK PREVENTION AND AVOIDANCE.pptx
DEADLOCK PREVENTION AND AVOIDANCE.pptxPugalenthiSomasundar
 
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
 
osvishal-160830131208 (1).pdf
osvishal-160830131208 (1).pdfosvishal-160830131208 (1).pdf
osvishal-160830131208 (1).pdfamadayshwan
 
Deadlock in operating systems
Deadlock in operating systemsDeadlock in operating systems
Deadlock in operating systemsjamunaashok
 
Deadlocks by wani zahoor
Deadlocks by wani zahoorDeadlocks by wani zahoor
Deadlocks by wani zahoorWani Zahoor
 
osvzjsjjdndnnssnnsnsndndndnndeadlock.pptx
osvzjsjjdndnnssnnsnsndndndnndeadlock.pptxosvzjsjjdndnnssnnsnsndndndnndeadlock.pptx
osvzjsjjdndnnssnnsnsndndndnndeadlock.pptxBhaskar271887
 
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
 
Os presentation final.pptxjjjjjdakajwsjjdhdfjff
Os presentation final.pptxjjjjjdakajwsjjdhdfjffOs presentation final.pptxjjjjjdakajwsjjdhdfjff
Os presentation final.pptxjjjjjdakajwsjjdhdfjffZeelGoyani
 
Lecture 6- Deadlocks (1) (1).pptx
Lecture 6- Deadlocks (1) (1).pptxLecture 6- Deadlocks (1) (1).pptx
Lecture 6- Deadlocks (1) (1).pptxAmanuelmergia
 
Operating-System-Neil-Eder-Report-PPT-Final (1).pptx
Operating-System-Neil-Eder-Report-PPT-Final (1).pptxOperating-System-Neil-Eder-Report-PPT-Final (1).pptx
Operating-System-Neil-Eder-Report-PPT-Final (1).pptxJuvil2
 

Similar to Unit 3 part 2(DEADLOCK) (20)

4.3 Deadlock [Autosaved].pptx
4.3 Deadlock [Autosaved].pptx4.3 Deadlock [Autosaved].pptx
4.3 Deadlock [Autosaved].pptx
 
DEADLOCK PREVENTION AND AVOIDANCE.pptx
DEADLOCK PREVENTION AND AVOIDANCE.pptxDEADLOCK PREVENTION AND AVOIDANCE.pptx
DEADLOCK PREVENTION AND AVOIDANCE.pptx
 
Deadlock
DeadlockDeadlock
Deadlock
 
OS 7.pptx
OS 7.pptxOS 7.pptx
OS 7.pptx
 
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
 
osvishal-160830131208 (1).pdf
osvishal-160830131208 (1).pdfosvishal-160830131208 (1).pdf
osvishal-160830131208 (1).pdf
 
Deadlock
DeadlockDeadlock
Deadlock
 
Deadlock
DeadlockDeadlock
Deadlock
 
Deadlock in operating systems
Deadlock in operating systemsDeadlock in operating systems
Deadlock in operating systems
 
Unit iv: Deadlocks
Unit iv: DeadlocksUnit iv: Deadlocks
Unit iv: Deadlocks
 
Rdbms
RdbmsRdbms
Rdbms
 
Deadlocks by wani zahoor
Deadlocks by wani zahoorDeadlocks by wani zahoor
Deadlocks by wani zahoor
 
Ch 4 deadlock
Ch 4 deadlockCh 4 deadlock
Ch 4 deadlock
 
Deadlocks2
Deadlocks2Deadlocks2
Deadlocks2
 
osvzjsjjdndnnssnnsnsndndndnndeadlock.pptx
osvzjsjjdndnnssnnsnsndndndnndeadlock.pptxosvzjsjjdndnnssnnsnsndndndnndeadlock.pptx
osvzjsjjdndnnssnnsnsndndndnndeadlock.pptx
 
Chapter06.ppt
Chapter06.pptChapter06.ppt
Chapter06.ppt
 
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
 
Os presentation final.pptxjjjjjdakajwsjjdhdfjff
Os presentation final.pptxjjjjjdakajwsjjdhdfjffOs presentation final.pptxjjjjjdakajwsjjdhdfjff
Os presentation final.pptxjjjjjdakajwsjjdhdfjff
 
Lecture 6- Deadlocks (1) (1).pptx
Lecture 6- Deadlocks (1) (1).pptxLecture 6- Deadlocks (1) (1).pptx
Lecture 6- Deadlocks (1) (1).pptx
 
Operating-System-Neil-Eder-Report-PPT-Final (1).pptx
Operating-System-Neil-Eder-Report-PPT-Final (1).pptxOperating-System-Neil-Eder-Report-PPT-Final (1).pptx
Operating-System-Neil-Eder-Report-PPT-Final (1).pptx
 

More from WajeehaBaig

Unit 2 part 2(Process)
Unit 2 part 2(Process)Unit 2 part 2(Process)
Unit 2 part 2(Process)WajeehaBaig
 
Unit 2 part 1(Process)
Unit 2 part 1(Process)Unit 2 part 1(Process)
Unit 2 part 1(Process)WajeehaBaig
 
lecture 1 (Part 2) kernal and its categories
lecture 1 (Part 2) kernal and its categorieslecture 1 (Part 2) kernal and its categories
lecture 1 (Part 2) kernal and its categoriesWajeehaBaig
 
Unit 3 part 1(DEADLOCK)
Unit 3 part 1(DEADLOCK)Unit 3 part 1(DEADLOCK)
Unit 3 part 1(DEADLOCK)WajeehaBaig
 
lecture 1 (Introduction to Operating System.)
lecture 1 (Introduction to Operating System.)lecture 1 (Introduction to Operating System.)
lecture 1 (Introduction to Operating System.)WajeehaBaig
 

More from WajeehaBaig (6)

File system
File systemFile system
File system
 
Unit 2 part 2(Process)
Unit 2 part 2(Process)Unit 2 part 2(Process)
Unit 2 part 2(Process)
 
Unit 2 part 1(Process)
Unit 2 part 1(Process)Unit 2 part 1(Process)
Unit 2 part 1(Process)
 
lecture 1 (Part 2) kernal and its categories
lecture 1 (Part 2) kernal and its categorieslecture 1 (Part 2) kernal and its categories
lecture 1 (Part 2) kernal and its categories
 
Unit 3 part 1(DEADLOCK)
Unit 3 part 1(DEADLOCK)Unit 3 part 1(DEADLOCK)
Unit 3 part 1(DEADLOCK)
 
lecture 1 (Introduction to Operating System.)
lecture 1 (Introduction to Operating System.)lecture 1 (Introduction to Operating System.)
lecture 1 (Introduction to Operating System.)
 

Recently uploaded

(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...RajaP95
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)Suman Mia
 
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
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLDeelipZope
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 

Recently uploaded (20)

(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
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
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCL
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 

Unit 3 part 2(DEADLOCK)

  • 1. Unit 3 – Part 2 Deadlock
  • 2. Methods for handling deadlock There are three ways to handle deadlock 1) Deadlock prevention or avoidance: The idea is to not let the system into deadlock state. One can zoom into each category individually, Prevention is done by negating one of above mentioned necessary conditions for deadlock. Avoidance is kind of futuristic in nature. By using strategy of “Avoidance”, we have to make an assumption. We need to ensure that all information about resources which process WILL need are known to us prior to execution of the process. 2) Deadlock detection and recovery: Let deadlock occur, then do preemption to handle it once occurred. 3) Ignore the problem all together: If deadlock is very rare, then let it happen and reboot the system. This is the approach that both Windows and UNIX take.
  • 3. 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. If resources have single instance: In this case for Deadlock detection we can run an algorithm to check for cycle in the Resource Allocation Graph. Presence of cycle in the graph is the sufficient condition for deadlock. In the diagram, resource 1 and resource 2 have single instances. There is a cycle R1 → P1 → R2 → P2. So, Deadlock is Confirmed.
  • 4. Deadlock Detection If there are multiple instances of resources: Detection of the cycle is necessary but not sufficient condition for deadlock detection, in this case, the system may or may not be in deadlock varies according to different situations.
  • 5. Deadlock Recovery A traditional operating system such as Windows doesn’t deal with deadlock recovery as it is time and space consuming process. Real-time operating systems use Deadlock recovery. Recovery method Killing the process: killing all the process involved in the deadlock. Killing process one by one. After killing each process check for deadlock again keep repeating the process till system recover from deadlock. Resource Preemption: Resources are preempted from the processes involved in the deadlock, preempted resources are allocated to other processes so that there is a possibility of recovering the system from deadlock. In this case, the system goes into starvation.
  • 6. Deadlock Avoidance Deadlock avoidance merely works to avoid deadlock; it does not totally prevent it. The basic idea here is to allocate resources only if the resulting global state is a safe state. In other words, unsafe states are avoided, meaning that deadlock is avoided as well. • When a process requests a resource, even if it is available, it is not immediately allocated to the process. Instead the systems assumes (pretends) it is so allocated. • With this assumption, along with advance knowledge of all the resources needed for all the processes, the system performs some analysis to decide whether or not granting the request is safe. • If the request is safe, the resource is granted to the requesting process. Otherwise, the resource is not given to the process at this time. This type of algorithm requires each site to have access to a global state (requiring too much storage and communication). Also the checking of the involved data structures must be done in a mutually exclusive fashion. With many sites and resources, it just takes too long.
  • 7. Deadlock avoidance can be done with Banker’s Algorithm. Banker’s Algorithm Bankers’s 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. Inputs to Banker’s Algorithm: • Max need of resources by each process. • Currently allocated resources by each process. • Max free available resources in the system. The request will only be granted under the below condition: • If the request made by the process is less than equal to max need to that process. • If the request made by the process is less than equal to the freely available resource in the system.
  • 8. Deadlock Prevention It is very important to prevent a deadlock before it can occur. So, the system checks each transaction before it is executed to make sure it does not lead to deadlock. If there is even a slight chance that a transaction may lead to deadlock in the future, it is never allowed to execute
  • 9. Deadlock Prevention This strategy involves designing a system that violates one of the four necessary conditions required for the occurrence of deadlock. This ensures that the system remains free from the deadlock. The various conditions of deadlock occurrence may be violated as- • Eliminate Mutual Exclusion • Eliminate Hold and Wait • Eliminate No Pre-emption • Eliminate Circular Wait
  • 10. Deadlock Prevention 1- Eliminate Mutual Exclusion To violate this condition, all the system resources must be such that they can be used in a shareable mode. In a system, there are always some resources which are mutually exclusive by nature. So, this condition can not be violated.
  • 11. Deadlock Prevention 2- Eliminate Hold and Wait This condition can be violated in the following ways- Approach-01: In this approach, • A process has to first request for all the resources it requires for execution. • Once it has acquired all the resources, only then it can start its execution. • This approach ensures that the process does not hold some resources and wait for other resources. Drawbacks- The drawbacks of this approach are- • It is less efficient. • It is not implementable since it is not possible to predict in advance which resources will be required during execution.
  • 12. Deadlock Prevention Approach-02: In this approach, • A process is allowed to acquire the resources it desires at the current moment. • After acquiring the resources, it start its execution. • Now before making any new request, it has to compulsorily release all the resources that it holds currently. • This approach is efficient and implementable. Approach-03: In this approach, • A timer is set after the process acquires any resource. • After the timer expires, a process has to compulsorily release the resource.
  • 13. Deadlock Prevention 3-Eliminate No Pre-emption This condition can by violated by forceful pre-emption. • Consider a process is holding some resources and request other resources that can not be immediately allocated to it. • Then, by forcefully pre-empting the currently held resources, the condition can be violated. • A process is allowed to forcefully pre-empt the resources possessed by some other process only if It is a high priority process or a system process. The victim process is in the waiting state.
  • 14. Deadlock Prevention 4-Eliminate Circular Wait This condition can be violated by not allowing the processes to wait for resources in a cyclic manner. To violate this condition, the following approach is followed- Approach A numerical number is assigned to every resource. Each process is allowed to request for the resources either in only increasing or only decreasing order of the resource number. In case increasing order is followed, if a process requires a lesser number resource, then it must release all the resources having larger number and vice versa. This approach is the most practical approach and implementable. However, this approach may cause starvation but will never lead to deadlock.