SlideShare a Scribd company logo
Deadlocks
A deadlock is a situation in which a set of processes are blocked because each process is holding
a resource and waiting for another resource acquired by some other process in the set.
1. System Model
A system consists of a finite set of resources distributed among processes. A resource may have
multiple instances and can be classified into:
 Preemptible Resources: Can be taken away from a process without side effects (e.g.,
CPU).
 Non-Preemptible Resources: Cannot be taken away until the process releases them
(e.g., printers, database locks).
Each process follows this sequence:
1. Request: A process requests a resource.
2. Use: The process uses the resource.
3. Release: The process releases the resource after use.
2. Deadlock Characterization
A deadlock occurs if the following four conditions hold simultaneously (Coffman’s Conditions):
1. Mutual Exclusion: At least one resource must be held in a non-shareable mode.
2. Hold and Wait: A process holding at least one resource is waiting to acquire additional
resources held by other processes.
3. No Preemption: A resource cannot be forcibly taken from a process; it must be released
voluntarily.
4. Circular Wait: A circular chain of processes exists where each process holds at least one
resource needed by the next process in the cycle.
3. Methods for Handling Deadlock
There are three general approaches:
1. Ignore the problem (Most common in operating systems like Windows and Linux).
2. Ensure the system never enters a deadlock state (Deadlock Prevention or Avoidance).
3. Allow deadlocks to occur, detect, and then recover (Deadlock Detection and
Recovery).
4. Deadlock Prevention
Deadlock prevention ensures that at least one of the four necessary conditions never holds:
1. Mutual Exclusion: Not possible for non-shareable resources, but for some resources,
virtualization can allow sharing.
2. Hold and Wait: A process must request all resources at once (increasing resource
contention).
3. No Preemption: If a process is holding a resource and requests another one that is not
available, it must release all held resources.
4. Circular Wait: Impose a total ordering of all resource types and require each process to
request resources in increasing order.
5. Deadlock Avoidance
Deadlock avoidance requires the system to dynamically decide whether a resource request
should be granted. This is done using algorithms like:
1. Resource Allocation Graph (RAG) Algorithm
o If a graph with request and allocation edges forms a cycle, deadlock might occur.
o Adding a claim edge (showing future requests) helps in avoidance.
2. Banker's Algorithm (Dijkstra's Algorithm)
o Used for multiple instances of resources.
o Ensures that after allocation, the system remains in a safe state (a state where at
least one sequence of execution is possible without leading to deadlock).
6. Deadlock Detection
If deadlock prevention or avoidance is not used, the system must detect deadlocks.
1. Single Instance of Each Resource Type
o A wait-for graph is constructed by removing resource nodes from the Resource
Allocation Graph.
o If a cycle is detected, deadlock exists.
2. Multiple Instances of Resources
o A modified Banker’s algorithm checks for circular wait conditions.
7. Recovery from Deadlock
Once a deadlock is detected, the system must recover using one of the following methods:
1. Process Termination
o Abort all deadlocked processes.
o Abort one process at a time until deadlock is resolved.
2. Resource Preemption
o Select a victim process, roll it back, and preempt its resources.
o Requires careful selection to avoid starvation.

More Related Content

PPT
Os module 2 d
PPTX
Deadlocks and Deadlock Detection Other Issues
PDF
ikh311-05
PPTX
Operating system - Deadlock
PPTX
Deadlocks
PPTX
Ch 4 deadlock
PPTX
Lecture 6- Deadlocks (1) (1).pptx
PPTX
Lecture 6- Deadlocks.pptx
Os module 2 d
Deadlocks and Deadlock Detection Other Issues
ikh311-05
Operating system - Deadlock
Deadlocks
Ch 4 deadlock
Lecture 6- Deadlocks (1) (1).pptx
Lecture 6- Deadlocks.pptx

Similar to Deadlocks with example in Operating System.docx (20)

DOCX
Module3
PPTX
4.3 Deadlock [Autosaved].pptx
PDF
“Understanding Distributed Deadlocks: Causes, Detection
DOCX
deadlock-operating-systems (1jjhkh).docx
PPTX
PPTX
Deadlockpresentation.pptx
PDF
Unit 3 part 2(DEADLOCK)
PPTX
Deadlock-in-Operating-Systems.pptx os os
PPTX
Deadlock and memory management -- Operating System
PPT
Principles of Operating system and types
PPT
OS Lecture 5.ppt
PDF
Deadlock in distribute system by saeed siddik
PPTX
Algorithm 4Chapter Four- Deadlock (5).pptx
PPTX
dead-locks and deadlock handling in operating systems.pptx
PPTX
Chapter_3_Deadlockos studentsforcomp.pptx
PPTX
Deadlockproj.pptx
PPTX
Deadlocks in operating system
PPTX
OS 7.pptx
PPTX
Deadlocks
Module3
4.3 Deadlock [Autosaved].pptx
“Understanding Distributed Deadlocks: Causes, Detection
deadlock-operating-systems (1jjhkh).docx
Deadlockpresentation.pptx
Unit 3 part 2(DEADLOCK)
Deadlock-in-Operating-Systems.pptx os os
Deadlock and memory management -- Operating System
Principles of Operating system and types
OS Lecture 5.ppt
Deadlock in distribute system by saeed siddik
Algorithm 4Chapter Four- Deadlock (5).pptx
dead-locks and deadlock handling in operating systems.pptx
Chapter_3_Deadlockos studentsforcomp.pptx
Deadlockproj.pptx
Deadlocks in operating system
OS 7.pptx
Deadlocks
Ad

More from vgowthami9 (20)

DOCX
IPV4 Protocol in data communication and networks.docx
DOCX
Random Access Protocols in data communication and networks.docx
DOCX
Data and Signal in data communication and networks.docx
DOCX
Introduction to Data Communication and Networks.docx
DOCX
Cascading Styles Sheets Overview .docx
DOCX
Introduction to XHTML / HTML 4.0 .docx
DOCX
Hyper Text Markup Language Tags Categories.docx
DOCX
Introduction to Hyper Text Markup Language.docx
DOCX
Advanced Tools for Data Analytics - Power Query.docx
DOCX
Data Cleaning and Preparation - Text Functions.docx
DOCX
Excel for Data Analytics - Basic Excel Formulas.docx
DOCX
Concept of Classification in Data Mining.docx
DOCX
Concept of Data Mining Architecture.docx
DOCX
Concept of Data Warehouse Architecture.docx
DOCX
Verification and Validation in Software Engineering.docx
DOCX
Software Reliability and Reusability.docx
DOCX
User Interface in Software Engineering.docx
DOCX
System Models in Software Engineering.docx
DOCX
Process Models in software Engineering.docx
DOCX
File Management in Operating System.docx
IPV4 Protocol in data communication and networks.docx
Random Access Protocols in data communication and networks.docx
Data and Signal in data communication and networks.docx
Introduction to Data Communication and Networks.docx
Cascading Styles Sheets Overview .docx
Introduction to XHTML / HTML 4.0 .docx
Hyper Text Markup Language Tags Categories.docx
Introduction to Hyper Text Markup Language.docx
Advanced Tools for Data Analytics - Power Query.docx
Data Cleaning and Preparation - Text Functions.docx
Excel for Data Analytics - Basic Excel Formulas.docx
Concept of Classification in Data Mining.docx
Concept of Data Mining Architecture.docx
Concept of Data Warehouse Architecture.docx
Verification and Validation in Software Engineering.docx
Software Reliability and Reusability.docx
User Interface in Software Engineering.docx
System Models in Software Engineering.docx
Process Models in software Engineering.docx
File Management in Operating System.docx
Ad

Recently uploaded (20)

PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
TR - Agricultural Crops Production NC III.pdf
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
Complications of Minimal Access Surgery at WLH
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PPTX
Institutional Correction lecture only . . .
PPTX
GDM (1) (1).pptx small presentation for students
PDF
Insiders guide to clinical Medicine.pdf
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
RMMM.pdf make it easy to upload and study
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PPTX
Lesson notes of climatology university.
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
Microbial disease of the cardiovascular and lymphatic systems
102 student loan defaulters named and shamed – Is someone you know on the list?
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
TR - Agricultural Crops Production NC III.pdf
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Complications of Minimal Access Surgery at WLH
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
2.FourierTransform-ShortQuestionswithAnswers.pdf
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Institutional Correction lecture only . . .
GDM (1) (1).pptx small presentation for students
Insiders guide to clinical Medicine.pdf
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
human mycosis Human fungal infections are called human mycosis..pptx
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
RMMM.pdf make it easy to upload and study
Module 4: Burden of Disease Tutorial Slides S2 2025
Lesson notes of climatology university.
Supply Chain Operations Speaking Notes -ICLT Program
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Microbial disease of the cardiovascular and lymphatic systems

Deadlocks with example in Operating System.docx

  • 1. Deadlocks A deadlock is a situation in which a set of processes are blocked because each process is holding a resource and waiting for another resource acquired by some other process in the set. 1. System Model A system consists of a finite set of resources distributed among processes. A resource may have multiple instances and can be classified into:  Preemptible Resources: Can be taken away from a process without side effects (e.g., CPU).  Non-Preemptible Resources: Cannot be taken away until the process releases them (e.g., printers, database locks). Each process follows this sequence: 1. Request: A process requests a resource. 2. Use: The process uses the resource. 3. Release: The process releases the resource after use. 2. Deadlock Characterization A deadlock occurs if the following four conditions hold simultaneously (Coffman’s Conditions): 1. Mutual Exclusion: At least one resource must be held in a non-shareable mode. 2. Hold and Wait: A process holding at least one resource is waiting to acquire additional resources held by other processes.
  • 2. 3. No Preemption: A resource cannot be forcibly taken from a process; it must be released voluntarily. 4. Circular Wait: A circular chain of processes exists where each process holds at least one resource needed by the next process in the cycle. 3. Methods for Handling Deadlock There are three general approaches: 1. Ignore the problem (Most common in operating systems like Windows and Linux). 2. Ensure the system never enters a deadlock state (Deadlock Prevention or Avoidance). 3. Allow deadlocks to occur, detect, and then recover (Deadlock Detection and Recovery). 4. Deadlock Prevention Deadlock prevention ensures that at least one of the four necessary conditions never holds: 1. Mutual Exclusion: Not possible for non-shareable resources, but for some resources, virtualization can allow sharing. 2. Hold and Wait: A process must request all resources at once (increasing resource contention). 3. No Preemption: If a process is holding a resource and requests another one that is not available, it must release all held resources. 4. Circular Wait: Impose a total ordering of all resource types and require each process to request resources in increasing order.
  • 3. 5. Deadlock Avoidance Deadlock avoidance requires the system to dynamically decide whether a resource request should be granted. This is done using algorithms like: 1. Resource Allocation Graph (RAG) Algorithm o If a graph with request and allocation edges forms a cycle, deadlock might occur. o Adding a claim edge (showing future requests) helps in avoidance. 2. Banker's Algorithm (Dijkstra's Algorithm) o Used for multiple instances of resources. o Ensures that after allocation, the system remains in a safe state (a state where at least one sequence of execution is possible without leading to deadlock). 6. Deadlock Detection If deadlock prevention or avoidance is not used, the system must detect deadlocks. 1. Single Instance of Each Resource Type o A wait-for graph is constructed by removing resource nodes from the Resource Allocation Graph. o If a cycle is detected, deadlock exists. 2. Multiple Instances of Resources o A modified Banker’s algorithm checks for circular wait conditions. 7. Recovery from Deadlock Once a deadlock is detected, the system must recover using one of the following methods: 1. Process Termination
  • 4. o Abort all deadlocked processes. o Abort one process at a time until deadlock is resolved. 2. Resource Preemption o Select a victim process, roll it back, and preempt its resources. o Requires careful selection to avoid starvation.