SlideShare a Scribd company logo
1 of 14
S.V.I.T.,Vasad
 NAME: RAJAN SHAH  TOPIC: DEADLOCK:
DEFINITION,
CHARACTERISTICS &
PREVENTION.
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 running.
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
THANK YOU

More Related Content

What's hot

Dead Lock in operating system
Dead Lock in operating systemDead Lock in operating system
Dead Lock in operating systemAli Haider
 
Critical section problem in operating system.
Critical section problem in operating system.Critical section problem in operating system.
Critical section problem in operating system.MOHIT DADU
 
Deadlocks in operating system
Deadlocks in operating systemDeadlocks in operating system
Deadlocks in operating systemSara Ali
 
Process in operating system
Process in operating systemProcess in operating system
Process in operating systemChetan Mahawar
 
Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]Ravindra Raju Kolahalam
 
Concurrency Control in Database Management System
Concurrency Control in Database Management SystemConcurrency Control in Database Management System
Concurrency Control in Database Management SystemJanki Shah
 
deadlock handling
deadlock handlingdeadlock handling
deadlock handlingSuraj Kumar
 
Lock based protocols
Lock based protocolsLock based protocols
Lock based protocolsChethanMp7
 
deadlock avoidance
deadlock avoidancedeadlock avoidance
deadlock avoidancewahab13
 
Operating system Dead lock
Operating system Dead lockOperating system Dead lock
Operating system Dead lockKaram Munir Butt
 
8. mutual exclusion in Distributed Operating Systems
8. mutual exclusion in Distributed Operating Systems8. mutual exclusion in Distributed Operating Systems
8. mutual exclusion in Distributed Operating SystemsDr Sandeep Kumar Poonia
 

What's hot (20)

Dead Lock in operating system
Dead Lock in operating systemDead Lock in operating system
Dead Lock in operating system
 
Critical section problem in operating system.
Critical section problem in operating system.Critical section problem in operating system.
Critical section problem in operating system.
 
Memory management
Memory managementMemory management
Memory management
 
Deadlocks in operating system
Deadlocks in operating systemDeadlocks in operating system
Deadlocks in operating system
 
Concurrency control
Concurrency controlConcurrency control
Concurrency control
 
Process in operating system
Process in operating systemProcess in operating system
Process in operating system
 
Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]
 
OS - Deadlock
OS - DeadlockOS - Deadlock
OS - Deadlock
 
Concurrency Control in Database Management System
Concurrency Control in Database Management SystemConcurrency Control in Database Management System
Concurrency Control in Database Management System
 
Processes and threads
Processes and threadsProcesses and threads
Processes and threads
 
deadlock handling
deadlock handlingdeadlock handling
deadlock handling
 
Operating system critical section
Operating system   critical sectionOperating system   critical section
Operating system critical section
 
File system structure
File system structureFile system structure
File system structure
 
Semaphore
SemaphoreSemaphore
Semaphore
 
Lock based protocols
Lock based protocolsLock based protocols
Lock based protocols
 
Process state in OS
Process state in OSProcess state in OS
Process state in OS
 
deadlock avoidance
deadlock avoidancedeadlock avoidance
deadlock avoidance
 
Operating system Dead lock
Operating system Dead lockOperating system Dead lock
Operating system Dead lock
 
Parallel processing
Parallel processingParallel processing
Parallel processing
 
8. mutual exclusion in Distributed Operating Systems
8. mutual exclusion in Distributed Operating Systems8. mutual exclusion in Distributed Operating Systems
8. mutual exclusion in Distributed Operating Systems
 

Similar to Deadlock- Operating System

4.3 Deadlock [Autosaved].pptx
4.3 Deadlock [Autosaved].pptx4.3 Deadlock [Autosaved].pptx
4.3 Deadlock [Autosaved].pptxDishaDwivedi2
 
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
 
Os case study word
Os case study wordOs case study word
Os case study wordDhol Yash
 
Deadlock and memory management -- Operating System
Deadlock and memory management -- Operating SystemDeadlock and memory management -- Operating System
Deadlock and memory management -- Operating SystemEktaVaswani2
 
Process Synchronization And Deadlocks
Process Synchronization And DeadlocksProcess Synchronization And Deadlocks
Process Synchronization And Deadlockstech2click
 
Deadlocks prefinal
Deadlocks prefinalDeadlocks prefinal
Deadlocks prefinalmarangburu42
 
Deadlocksprefinal 161014115456
Deadlocksprefinal 161014115456Deadlocksprefinal 161014115456
Deadlocksprefinal 161014115456marangburu42
 
Deadlock and Banking Algorithm
Deadlock and Banking AlgorithmDeadlock and Banking Algorithm
Deadlock and Banking AlgorithmMD.ANISUR RAHMAN
 
Deadlock- System model, resource types, deadlock problem, deadlock characteri...
Deadlock- System model, resource types, deadlock problem, deadlock characteri...Deadlock- System model, resource types, deadlock problem, deadlock characteri...
Deadlock- System model, resource types, deadlock problem, deadlock characteri...Wakil Kumar
 
Deadlock in Operating System
Deadlock in Operating SystemDeadlock in Operating System
Deadlock in Operating SystemAUST
 
Deadlocks 160928121516-160928183232
Deadlocks 160928121516-160928183232Deadlocks 160928121516-160928183232
Deadlocks 160928121516-160928183232marangburu42
 

Similar to Deadlock- Operating System (20)

Deadlocks
DeadlocksDeadlocks
Deadlocks
 
Operating system Deadlock
Operating system DeadlockOperating system Deadlock
Operating system Deadlock
 
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
 
Module3
Module3Module3
Module3
 
Distributed deadlock
Distributed deadlockDistributed deadlock
Distributed deadlock
 
Os module 2 d
Os module 2 dOs module 2 d
Os module 2 d
 
Os case study word
Os case study wordOs case study word
Os case study word
 
Deadlock and memory management -- Operating System
Deadlock and memory management -- Operating SystemDeadlock and memory management -- Operating System
Deadlock and memory management -- Operating System
 
OS 7.pptx
OS 7.pptxOS 7.pptx
OS 7.pptx
 
Process Synchronization And Deadlocks
Process Synchronization And DeadlocksProcess Synchronization And Deadlocks
Process Synchronization And Deadlocks
 
Deadlocks
DeadlocksDeadlocks
Deadlocks
 
Deadlocks prefinal
Deadlocks prefinalDeadlocks prefinal
Deadlocks prefinal
 
Deadlocksprefinal 161014115456
Deadlocksprefinal 161014115456Deadlocksprefinal 161014115456
Deadlocksprefinal 161014115456
 
Deadlock and Banking Algorithm
Deadlock and Banking AlgorithmDeadlock and Banking Algorithm
Deadlock and Banking Algorithm
 
Deadlock- System model, resource types, deadlock problem, deadlock characteri...
Deadlock- System model, resource types, deadlock problem, deadlock characteri...Deadlock- System model, resource types, deadlock problem, deadlock characteri...
Deadlock- System model, resource types, deadlock problem, deadlock characteri...
 
Deadlock in Operating System
Deadlock in Operating SystemDeadlock in Operating System
Deadlock in Operating System
 
Deadlocks final
Deadlocks finalDeadlocks final
Deadlocks final
 
Deadlocks 160928121516-160928183232
Deadlocks 160928121516-160928183232Deadlocks 160928121516-160928183232
Deadlocks 160928121516-160928183232
 

More from Rajan Shah

Xml dtd- Document Type Definition- Web Technology
Xml dtd- Document Type Definition- Web TechnologyXml dtd- Document Type Definition- Web Technology
Xml dtd- Document Type Definition- Web TechnologyRajan Shah
 
Timing and control circuit
Timing and control circuitTiming and control circuit
Timing and control circuitRajan Shah
 
Rethrowing exception- JAVA
Rethrowing exception- JAVARethrowing exception- JAVA
Rethrowing exception- JAVARajan Shah
 
Np Completeness
Np CompletenessNp Completeness
Np CompletenessRajan Shah
 
Files and streams In Java
Files and streams In JavaFiles and streams In Java
Files and streams In JavaRajan Shah
 
Data Reduction
Data ReductionData Reduction
Data ReductionRajan Shah
 
Cyclic Redundancy Check
Cyclic Redundancy CheckCyclic Redundancy Check
Cyclic Redundancy CheckRajan Shah
 
Client server s/w Engineering
Client server s/w EngineeringClient server s/w Engineering
Client server s/w EngineeringRajan Shah
 
Bluetooth protocol
Bluetooth protocolBluetooth protocol
Bluetooth protocolRajan Shah
 

More from Rajan Shah (10)

Xml dtd- Document Type Definition- Web Technology
Xml dtd- Document Type Definition- Web TechnologyXml dtd- Document Type Definition- Web Technology
Xml dtd- Document Type Definition- Web Technology
 
Timing and control circuit
Timing and control circuitTiming and control circuit
Timing and control circuit
 
Rethrowing exception- JAVA
Rethrowing exception- JAVARethrowing exception- JAVA
Rethrowing exception- JAVA
 
Np Completeness
Np CompletenessNp Completeness
Np Completeness
 
Lex Tool
Lex ToolLex Tool
Lex Tool
 
Files and streams In Java
Files and streams In JavaFiles and streams In Java
Files and streams In Java
 
Data Reduction
Data ReductionData Reduction
Data Reduction
 
Cyclic Redundancy Check
Cyclic Redundancy CheckCyclic Redundancy Check
Cyclic Redundancy Check
 
Client server s/w Engineering
Client server s/w EngineeringClient server s/w Engineering
Client server s/w Engineering
 
Bluetooth protocol
Bluetooth protocolBluetooth protocol
Bluetooth protocol
 

Recently uploaded

An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...Chandu841456
 
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
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfme23b1001
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfROCENODodongVILLACER
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
pipeline in computer architecture design
pipeline in computer architecture  designpipeline in computer architecture  design
pipeline in computer architecture designssuser87fa0c1
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)Dr SOUNDIRARAJ N
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
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
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvLewisJB
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)dollysharma2066
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxKartikeyaDwivedi3
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHC Sai Kiran
 

Recently uploaded (20)

An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...
 
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
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdf
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdf
 
POWER SYSTEMS-1 Complete notes examples
POWER SYSTEMS-1 Complete notes  examplesPOWER SYSTEMS-1 Complete notes  examples
POWER SYSTEMS-1 Complete notes examples
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
pipeline in computer architecture design
pipeline in computer architecture  designpipeline in computer architecture  design
pipeline in computer architecture design
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
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
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
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
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvv
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptx
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECH
 

Deadlock- Operating System

  • 1. S.V.I.T.,Vasad  NAME: RAJAN SHAH  TOPIC: DEADLOCK: DEFINITION, CHARACTERISTICS & PREVENTION.
  • 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 running.
  • 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