SlideShare a Scribd company logo
DEADLOCKS
CHAPTER – 7
DEADLOCK
 Definition:
 A deadlock is a situation in which two computer
programs sharing the same resource are effectively
preventing each other from accessing the resource,
resulting in both programs ceasing to function.
 The reason, why earliest computer OS ran only one
program
at a time.
 A set of processes is deadlocked if each process in
the set is waiting for an event that only another
process can trigger.
CONTINUE...
 As all the processes in the set are waiting for an
another process to trigger an event that could wake
up any of the other members of the set, all the
processes would wait for ever.
 None of the processes can run, none of them can
release any resource, and thus none can be awakened.
 The no. of processes and the no. and kind of
resources processed and requested are unimp..
This kind of request holds for any kind of resource
and is called Resource Deadlock.
CHARACTERISTICS OF DEADLOCK
 A deadlock situation can arise if the following four
conditions hold simultaneously in a system:
1. Mutual Exclusion
2. Hold & Wait
3. No Pre-emption
4. Circular wait.
PREVENTION TECHNIQUES
 The methods to prevent the Deadlock
are:
1. Attacking the Mutual Exclusion
Condition.
2. Attacking the Hold & Wait Condition.
3. Attacking the No Pre-emption
Condition.
4. Attacking the Circular Wait Condition.
ATTACKING THE MUTUAL EXCLUSION
CONDITION
 Mutual Exclusion: For two processes, if any one
process is accessing the common resource then the
another process is excluded from accessing the
resource.
 Thus, each resource is either currently allocated to
exactly one process or it is available for other
process to access it. Two processes can’t
simultaneously access the common resource.
EXAMPLE
 It is clear that by allowing two processes to write on the
printer
simultaneously will lead to chaos.
 Actually, the only process which requests the physical
printer is the printer daemon.
 Printer daemon never requests any other resource, so
the deadlock can be eliminated and also it prints only
after the complete o/p file is available.
 But this could in itself lead to deadlock for two processes
having finished their part, but not all, of their o/p, and can’t
continue.
 Thus, avoiding to assign a resource unless not
absolutely necessary and try to make less
processes request for the resource.
ATTACKING THE HOLD & WAIT
CONDITION
 Hold and Wait: In this scenario, processes currently
holding resource can request new resource to
complete its task.
 If the process requests all the resources before
starting the execution, deadlocks can be eliminated.
 I.E. if everything is available, process will be
allocated whatever it needs and can run to
completion.
 Whereas, if one or more of the requested resource
is/are busy, then nothing will be allocated and the
process would just wait for the resource to become
free and enter the critical region.
 The problem that how many resources does a
process may need can’t be known until it has started
EXAMPLE
 Consider a process, that reads data from an i/p tape,
analyzes it for an hour, and then writes an o/p tape as
well as plotting the results.
 Thus, if all resources are requested in adv, the process
will tie up the o/p tape and the plotter for an hour.
 Thus, this method wastes the resources as for an
hour no other process would be able to use the
plotter and the o/p tape.
ATTACKING THE NO PRE-EMPTION CONDITION
 No Pre-emption: Once a process holds a resource, it
can’t be taken away by another process or the kernel
and resource can only be voluntarily released by the
process.
 Example: if a process is assigned a printer and is in the
middle of printing its output, forcibly taking away the
printer because the plotter needed isn’t available is not
possible.
 Thus, a resource can be used only if the process
holding it, releases it voluntarily.
ATTACKING THE CIRCULAR WAIT
CONDITION
 Circular wait: Each process is waiting to obtain a
resource which is held by another process.
 The circular wait can be eliminated by a rule that if a
process is holding a resource at the moment then it
can’t request for other resource, and if it wants to
access the other resource then it must release the first
one.
 Another way to avoid the circular wait is to provide a
global numbering of all the resources.
 A process can request whenever it wants, but all the
request
must be made in numerical order.
EXAMPLE
 Consider the following resources numbered as below:
1. Image setter
2. Scanner
3. Plotter
4. Tape-Drive
5. CD-ROM drive.
• A process may request first a printer and then a tape drive, but it can’t request
first a plotter and then a printer.
Example
 Here, if A requests for j ;
i>j, then A is not allowed
to request j because
that is lower than what it
already has.
 Similarly, if B requests
for i; i<j, then B is not
allowed to request for i.
 Thus, either way
deadlock
is not possible.
A
i
B
j

More Related Content

Similar to Deadlocks

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
 
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 7.pptx
OS 7.pptxOS 7.pptx
OS 7.pptx
ZainabShahzad9
 
Os module 2 d
Os module 2 dOs module 2 d
Os module 2 d
Gichelle Amon
 
Module3
Module3Module3
Module3
dilshad begum
 
Os case study word
Os case study wordOs case study word
Os case study word
Dhol Yash
 
Distributed deadlock
Distributed deadlockDistributed deadlock
Distributed deadlock
Md. Mahedi Mahfuj
 
Deadlocks prefinal
Deadlocks prefinalDeadlocks prefinal
Deadlocks prefinal
marangburu42
 
Deadlocksprefinal 161014115456
Deadlocksprefinal 161014115456Deadlocksprefinal 161014115456
Deadlocksprefinal 161014115456
marangburu42
 
Deadlocks
DeadlocksDeadlocks
Deadlocks
Shipra Swati
 
Deadlocks final
Deadlocks finalDeadlocks final
Deadlocks final
marangburu42
 
Deadlock and Banking Algorithm
Deadlock and Banking AlgorithmDeadlock and Banking Algorithm
Deadlock and Banking Algorithm
MD.ANISUR RAHMAN
 
Deadlocks 160928121516-160928183232
Deadlocks 160928121516-160928183232Deadlocks 160928121516-160928183232
Deadlocks 160928121516-160928183232
marangburu42
 
ikh311-05
ikh311-05ikh311-05
ikh311-05
Anung Ariwibowo
 
Deadlock in Operating System
Deadlock in Operating SystemDeadlock in Operating System
Deadlock in Operating System
SanthiNivas
 
Process Synchronization And Deadlocks
Process Synchronization And DeadlocksProcess Synchronization And Deadlocks
Process Synchronization And Deadlocks
tech2click
 
Deadlock in Operating System
Deadlock in Operating SystemDeadlock in Operating System
Deadlock in Operating System
AUST
 
Deadlock and memory management -- Operating System
Deadlock and memory management -- Operating SystemDeadlock and memory management -- Operating System
Deadlock and memory management -- Operating System
EktaVaswani2
 
OS K.Nishitha presentation on dead locks .pptx
OS K.Nishitha presentation on dead locks .pptxOS K.Nishitha presentation on dead locks .pptx
OS K.Nishitha presentation on dead locks .pptx
loksaikls
 

Similar to Deadlocks (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
 
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 7.pptx
OS 7.pptxOS 7.pptx
OS 7.pptx
 
Os module 2 d
Os module 2 dOs module 2 d
Os module 2 d
 
Module3
Module3Module3
Module3
 
Os case study word
Os case study wordOs case study word
Os case study word
 
Distributed deadlock
Distributed deadlockDistributed deadlock
Distributed deadlock
 
Deadlocks prefinal
Deadlocks prefinalDeadlocks prefinal
Deadlocks prefinal
 
Deadlocksprefinal 161014115456
Deadlocksprefinal 161014115456Deadlocksprefinal 161014115456
Deadlocksprefinal 161014115456
 
Deadlocks
DeadlocksDeadlocks
Deadlocks
 
Deadlocks final
Deadlocks finalDeadlocks final
Deadlocks final
 
Deadlock and Banking Algorithm
Deadlock and Banking AlgorithmDeadlock and Banking Algorithm
Deadlock and Banking Algorithm
 
Deadlocks 160928121516-160928183232
Deadlocks 160928121516-160928183232Deadlocks 160928121516-160928183232
Deadlocks 160928121516-160928183232
 
ikh311-05
ikh311-05ikh311-05
ikh311-05
 
Deadlock in Operating System
Deadlock in Operating SystemDeadlock in Operating System
Deadlock in Operating System
 
Process Synchronization And Deadlocks
Process Synchronization And DeadlocksProcess Synchronization And Deadlocks
Process Synchronization And Deadlocks
 
Deadlock in Operating System
Deadlock in Operating SystemDeadlock in Operating System
Deadlock in Operating System
 
Deadlock and memory management -- Operating System
Deadlock and memory management -- Operating SystemDeadlock and memory management -- Operating System
Deadlock and memory management -- Operating System
 
OS K.Nishitha presentation on dead locks .pptx
OS K.Nishitha presentation on dead locks .pptxOS K.Nishitha presentation on dead locks .pptx
OS K.Nishitha presentation on dead locks .pptx
 

More from Munazza-Mah-Jabeen

Virtual Functions
Virtual FunctionsVirtual Functions
Virtual Functions
Munazza-Mah-Jabeen
 
The Standard Template Library
The Standard Template LibraryThe Standard Template Library
The Standard Template Library
Munazza-Mah-Jabeen
 
Object-Oriented Software
Object-Oriented SoftwareObject-Oriented Software
Object-Oriented Software
Munazza-Mah-Jabeen
 
Templates and Exceptions
 Templates and Exceptions Templates and Exceptions
Templates and Exceptions
Munazza-Mah-Jabeen
 
Dictionaries and Sets
Dictionaries and SetsDictionaries and Sets
Dictionaries and Sets
Munazza-Mah-Jabeen
 
More About Strings
More About StringsMore About Strings
More About Strings
Munazza-Mah-Jabeen
 
Streams and Files
Streams and FilesStreams and Files
Streams and Files
Munazza-Mah-Jabeen
 
Lists and Tuples
Lists and TuplesLists and Tuples
Lists and Tuples
Munazza-Mah-Jabeen
 
Files and Exceptions
Files and ExceptionsFiles and Exceptions
Files and Exceptions
Munazza-Mah-Jabeen
 
Functions
FunctionsFunctions
Pointers
PointersPointers
Repitition Structure
Repitition StructureRepitition Structure
Repitition Structure
Munazza-Mah-Jabeen
 
Inheritance
InheritanceInheritance
Inheritance
Munazza-Mah-Jabeen
 
Operator Overloading
Operator OverloadingOperator Overloading
Operator Overloading
Munazza-Mah-Jabeen
 
Memory Management
Memory ManagementMemory Management
Memory Management
Munazza-Mah-Jabeen
 
Arrays and Strings
Arrays and StringsArrays and Strings
Arrays and Strings
Munazza-Mah-Jabeen
 
Objects and Classes
Objects and ClassesObjects and Classes
Objects and Classes
Munazza-Mah-Jabeen
 
Functions
FunctionsFunctions
Structures
StructuresStructures
Structures
Munazza-Mah-Jabeen
 
Loops and Decisions
Loops and DecisionsLoops and Decisions
Loops and Decisions
Munazza-Mah-Jabeen
 

More from Munazza-Mah-Jabeen (20)

Virtual Functions
Virtual FunctionsVirtual Functions
Virtual Functions
 
The Standard Template Library
The Standard Template LibraryThe Standard Template Library
The Standard Template Library
 
Object-Oriented Software
Object-Oriented SoftwareObject-Oriented Software
Object-Oriented Software
 
Templates and Exceptions
 Templates and Exceptions Templates and Exceptions
Templates and Exceptions
 
Dictionaries and Sets
Dictionaries and SetsDictionaries and Sets
Dictionaries and Sets
 
More About Strings
More About StringsMore About Strings
More About Strings
 
Streams and Files
Streams and FilesStreams and Files
Streams and Files
 
Lists and Tuples
Lists and TuplesLists and Tuples
Lists and Tuples
 
Files and Exceptions
Files and ExceptionsFiles and Exceptions
Files and Exceptions
 
Functions
FunctionsFunctions
Functions
 
Pointers
PointersPointers
Pointers
 
Repitition Structure
Repitition StructureRepitition Structure
Repitition Structure
 
Inheritance
InheritanceInheritance
Inheritance
 
Operator Overloading
Operator OverloadingOperator Overloading
Operator Overloading
 
Memory Management
Memory ManagementMemory Management
Memory Management
 
Arrays and Strings
Arrays and StringsArrays and Strings
Arrays and Strings
 
Objects and Classes
Objects and ClassesObjects and Classes
Objects and Classes
 
Functions
FunctionsFunctions
Functions
 
Structures
StructuresStructures
Structures
 
Loops and Decisions
Loops and DecisionsLoops and Decisions
Loops and Decisions
 

Recently uploaded

How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience
Wahiba Chair Training & Consulting
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
AyyanKhan40
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
GeorgeMilliken2
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
mulvey2
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
adhitya5119
 
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptxChapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Denish Jangid
 
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skillsspot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
haiqairshad
 
Reimagining Your Library Space: How to Increase the Vibes in Your Library No ...
Reimagining Your Library Space: How to Increase the Vibes in Your Library No ...Reimagining Your Library Space: How to Increase the Vibes in Your Library No ...
Reimagining Your Library Space: How to Increase the Vibes in Your Library No ...
Diana Rendina
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
adhitya5119
 
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
Nguyen Thanh Tu Collection
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
Celine George
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
TechSoup
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
Colégio Santa Teresinha
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
imrankhan141184
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
 
UGC NET Exam Paper 1- Unit 1:Teaching Aptitude
UGC NET Exam Paper 1- Unit 1:Teaching AptitudeUGC NET Exam Paper 1- Unit 1:Teaching Aptitude
UGC NET Exam Paper 1- Unit 1:Teaching Aptitude
S. Raj Kumar
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
Nguyen Thanh Tu Collection
 

Recently uploaded (20)

How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
 
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptxChapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptx
 
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skillsspot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
 
Reimagining Your Library Space: How to Increase the Vibes in Your Library No ...
Reimagining Your Library Space: How to Increase the Vibes in Your Library No ...Reimagining Your Library Space: How to Increase the Vibes in Your Library No ...
Reimagining Your Library Space: How to Increase the Vibes in Your Library No ...
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
 
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
 
UGC NET Exam Paper 1- Unit 1:Teaching Aptitude
UGC NET Exam Paper 1- Unit 1:Teaching AptitudeUGC NET Exam Paper 1- Unit 1:Teaching Aptitude
UGC NET Exam Paper 1- Unit 1:Teaching Aptitude
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
 

Deadlocks

  • 2. DEADLOCK  Definition:  A deadlock is a situation in which two computer programs sharing the same resource are effectively preventing each other from accessing the resource, resulting in both programs ceasing to function.  The reason, why earliest computer OS ran only one program at a time.  A set of processes is deadlocked if each process in the set is waiting for an event that only another process can trigger.
  • 3. CONTINUE...  As all the processes in the set are waiting for an another process to trigger an event that could wake up any of the other members of the set, all the processes would wait for ever.  None of the processes can run, none of them can release any resource, and thus none can be awakened.  The no. of processes and the no. and kind of resources processed and requested are unimp.. This kind of request holds for any kind of resource and is called Resource Deadlock.
  • 4. CHARACTERISTICS OF DEADLOCK  A deadlock situation can arise if the following four conditions hold simultaneously in a system: 1. Mutual Exclusion 2. Hold & Wait 3. No Pre-emption 4. Circular wait.
  • 5. PREVENTION TECHNIQUES  The methods to prevent the Deadlock are: 1. Attacking the Mutual Exclusion Condition. 2. Attacking the Hold & Wait Condition. 3. Attacking the No Pre-emption Condition. 4. Attacking the Circular Wait Condition.
  • 6. ATTACKING THE MUTUAL EXCLUSION CONDITION  Mutual Exclusion: For two processes, if any one process is accessing the common resource then the another process is excluded from accessing the resource.  Thus, each resource is either currently allocated to exactly one process or it is available for other process to access it. Two processes can’t simultaneously access the common resource.
  • 7. EXAMPLE  It is clear that by allowing two processes to write on the printer simultaneously will lead to chaos.  Actually, the only process which requests the physical printer is the printer daemon.  Printer daemon never requests any other resource, so the deadlock can be eliminated and also it prints only after the complete o/p file is available.  But this could in itself lead to deadlock for two processes having finished their part, but not all, of their o/p, and can’t continue.  Thus, avoiding to assign a resource unless not absolutely necessary and try to make less processes request for the resource.
  • 8. ATTACKING THE HOLD & WAIT CONDITION  Hold and Wait: In this scenario, processes currently holding resource can request new resource to complete its task.  If the process requests all the resources before starting the execution, deadlocks can be eliminated.  I.E. if everything is available, process will be allocated whatever it needs and can run to completion.  Whereas, if one or more of the requested resource is/are busy, then nothing will be allocated and the process would just wait for the resource to become free and enter the critical region.  The problem that how many resources does a process may need can’t be known until it has started
  • 9. EXAMPLE  Consider a process, that reads data from an i/p tape, analyzes it for an hour, and then writes an o/p tape as well as plotting the results.  Thus, if all resources are requested in adv, the process will tie up the o/p tape and the plotter for an hour.  Thus, this method wastes the resources as for an hour no other process would be able to use the plotter and the o/p tape.
  • 10. ATTACKING THE NO PRE-EMPTION CONDITION  No Pre-emption: Once a process holds a resource, it can’t be taken away by another process or the kernel and resource can only be voluntarily released by the process.  Example: if a process is assigned a printer and is in the middle of printing its output, forcibly taking away the printer because the plotter needed isn’t available is not possible.  Thus, a resource can be used only if the process holding it, releases it voluntarily.
  • 11. ATTACKING THE CIRCULAR WAIT CONDITION  Circular wait: Each process is waiting to obtain a resource which is held by another process.  The circular wait can be eliminated by a rule that if a process is holding a resource at the moment then it can’t request for other resource, and if it wants to access the other resource then it must release the first one.  Another way to avoid the circular wait is to provide a global numbering of all the resources.  A process can request whenever it wants, but all the request must be made in numerical order.
  • 12. EXAMPLE  Consider the following resources numbered as below: 1. Image setter 2. Scanner 3. Plotter 4. Tape-Drive 5. CD-ROM drive. • A process may request first a printer and then a tape drive, but it can’t request first a plotter and then a printer.
  • 13. Example  Here, if A requests for j ; i>j, then A is not allowed to request j because that is lower than what it already has.  Similarly, if B requests for i; i<j, then B is not allowed to request for i.  Thus, either way deadlock is not possible. A i B j