Deadlocks in operating system
description
Transcript of Deadlocks in operating system
![Page 1: Deadlocks in operating system](https://reader033.fdocuments.net/reader033/viewer/2022061122/546991eeaf7959c32b8b5a47/html5/thumbnails/1.jpg)
DEADLOCKS IN OPERATING SYSTEM
“Cris
es and deadlock
s when th
ey
occur
have at
least this
advantage, that t
hey force
us to
think.”- Ja
waharlal N
ehru (1889 -
1964) Indian politi
cal le
ader
![Page 2: Deadlocks in operating system](https://reader033.fdocuments.net/reader033/viewer/2022061122/546991eeaf7959c32b8b5a47/html5/thumbnails/2.jpg)
OPERATING SYSTEMPresented by :
Wajiha SiddiquiSara Ali Aisha Hameed
![Page 3: Deadlocks in operating system](https://reader033.fdocuments.net/reader033/viewer/2022061122/546991eeaf7959c32b8b5a47/html5/thumbnails/3.jpg)
1. The Deadlock Problem
2. Deadlock Characterization
3. Deadlock Modeling
4. Resource Allocation Graph
5. Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance Deadlock Detection Recovery from Deadlock
![Page 4: Deadlocks in operating system](https://reader033.fdocuments.net/reader033/viewer/2022061122/546991eeaf7959c32b8b5a47/html5/thumbnails/4.jpg)
WHAT ARE DEADLOCKS???
A set of blocked processes each
holding a resource and waiting to
acquire a resource held by another
process in the set.
o Example Process-1 requests the printer, gets it Process-2 requests the tape unit, gets it Process-1 and Process-1 requests the tape unit, waits Process-2 are Process-2 requests the printer, waits deadlocked!
![Page 5: Deadlocks in operating system](https://reader033.fdocuments.net/reader033/viewer/2022061122/546991eeaf7959c32b8b5a47/html5/thumbnails/5.jpg)
FOUR CONDITIONS FOR DEADLOCKS???
1. Mutual Exclusion Condition
2. Hold & Wait Condition
3. No Preemption Condition
4. Circular Wait Condition
![Page 6: Deadlocks in operating system](https://reader033.fdocuments.net/reader033/viewer/2022061122/546991eeaf7959c32b8b5a47/html5/thumbnails/6.jpg)
DEADLOCK MODELING???
Modeled with directed graphs
![Page 7: Deadlocks in operating system](https://reader033.fdocuments.net/reader033/viewer/2022061122/546991eeaf7959c32b8b5a47/html5/thumbnails/7.jpg)
HOW DEADLOCKS OCCUR?
![Page 8: Deadlocks in operating system](https://reader033.fdocuments.net/reader033/viewer/2022061122/546991eeaf7959c32b8b5a47/html5/thumbnails/8.jpg)
HOW DEADLOCKS CAN BE AVOIDED???
![Page 9: Deadlocks in operating system](https://reader033.fdocuments.net/reader033/viewer/2022061122/546991eeaf7959c32b8b5a47/html5/thumbnails/9.jpg)
RESOURCE ALLOCATION GRAPHS???
CIRCLES represents processes
SQUARE represents classes of identical resources
SMALL SQUARES DRAWN INSIDE LARGE SQUARES Indicate separate identical resources of each class
![Page 10: Deadlocks in operating system](https://reader033.fdocuments.net/reader033/viewer/2022061122/546991eeaf7959c32b8b5a47/html5/thumbnails/10.jpg)
If the resource allocation graph contains no cycles then there is no deadlock in the system at that instance.
If there is a cycle
o If there is only one instance per resource type than there is a deadlocko If there is more than once instance for some resource type than there may
or may not be a deadlock
![Page 11: Deadlocks in operating system](https://reader033.fdocuments.net/reader033/viewer/2022061122/546991eeaf7959c32b8b5a47/html5/thumbnails/11.jpg)
EXAMPLE OF A RESOURCE ALLOCATION GRAPH
![Page 12: Deadlocks in operating system](https://reader033.fdocuments.net/reader033/viewer/2022061122/546991eeaf7959c32b8b5a47/html5/thumbnails/12.jpg)
HOW TO HANDLE DEADLOCKS???
• Four major areas of interest in deadlock research
- Deadlock Prevention
- Deadlock Avoidance
- Deadlock Detection
- Deadlock Recovery
![Page 13: Deadlocks in operating system](https://reader033.fdocuments.net/reader033/viewer/2022061122/546991eeaf7959c32b8b5a47/html5/thumbnails/13.jpg)
DEADLOCK PREVENTION???
• Prevention eliminates one of four conditions
1. Elimination Of Mutual Exclusion
2. Elimination Of Hold & Wait Condition
3. Elimination Of No Preemption Condition
4. Elimination Of Circular Wait Condition
![Page 14: Deadlocks in operating system](https://reader033.fdocuments.net/reader033/viewer/2022061122/546991eeaf7959c32b8b5a47/html5/thumbnails/14.jpg)
DEADLOCK AVOIDANCE???
• Maximum requirements of
each resource must be stated
in advance by each process.
• Two Approaches
• Two Algorithmso Resource Allocation Algorithmso The Banker’s Algorithm
![Page 15: Deadlocks in operating system](https://reader033.fdocuments.net/reader033/viewer/2022061122/546991eeaf7959c32b8b5a47/html5/thumbnails/15.jpg)
DEADLOCK DETECTION???
• Determines if deadlock has occurred• Identifies those processes & resources
involved in the deadlock• Algorithms can incur significant
runtime overhead
![Page 16: Deadlocks in operating system](https://reader033.fdocuments.net/reader033/viewer/2022061122/546991eeaf7959c32b8b5a47/html5/thumbnails/16.jpg)
RECOVERY FROM DEADLOCKS???
• Process Terminationo Abort all deadlocked processes.o Abort one process at a time until
the deadlock cycle is eliminated.
• Resource Preemptiono Selecting a victimo Rollbacko Starvation
![Page 17: Deadlocks in operating system](https://reader033.fdocuments.net/reader033/viewer/2022061122/546991eeaf7959c32b8b5a47/html5/thumbnails/17.jpg)