DEAD LOCKS
S.SaiNishitha
22011A0527
what is a DEADLOCK?
• Deadlock is a situation in which group of processes are
blocked.
• Each process acquires a resource needed for its completion
• Simultaneously the processes waits for the resources to be
released by others – thus making impossible for any process to
proceed.
CONDITIONS FOR DEADLOCK TO OCCUR
 Mutual Exclusion: At least one resource must be held in a non-
sharable mode, meaning only one process can use it at a time.
 Hold and Wait: A process must be holding at least one resource is
waiting to acquire additional resources held by another processes.
 No Preemption: Resources cannot be forcibly taken away from a
process; they must be released voluntarily.
 Circular Wait: A circular chain of two or more processes exists,
where each process is waiting for a resource held by the next
process in the chain.
METHODS FOR HANDLING DEADLOCKS
 Ensure that the system will never enter a deadlock state
 Allow the system to enter a deadlock and then recover
 Ignore the problem and pretend that deadlock never occurred in the
system.This is the simplest and most used in OS.
 The first and second methods need techniques to be developed and
implemented.These methods are Deadlock Prevention and Deadlock
Avoidance.
DEADLOCK PREVENTION
INDIRECT :-
prevent the
occurrence of
Mutual Exclusion, Hold
and Wait, No
Preemption
DIRECT :-
prevent the
occurrence of Circular
Wait
1. Mutual exclusion – not required for sharable resources,must
hold for non sharable resources.
2. Hold and wait – must guarantee that whenever a process
request a resource,it does not hold any other resources.
3.No Preemption – can be prevented in many ways.
• If a process that is holding some resources requests
another resources that cannot be immediately allocated to
it,then all resources currently being held are released
4.Circular wait -- impose a total ordering of resources types and require that each
process requests resources in an increasing order of enumeration.
• Preempted resources are added to the list of resources for which
the process is waiting
• Process will be restarted only when it can regain its old
resources,as well as the new resources that it is requesting
RECOVERY FROM DEADLOCK
1.PROCESS TERMINATION ->
- Abort all deadlock processes
-Abort one process at a time until deadlock cycle is eliminated
-In partial termination process choosen to abort
o Priority of process
o How long process has completed and how much longer
to completion
o Resources process has used
o How many resources process need to complete
2.RESOURCE PREEMPTION ->
- successively preempt resources from processes and give it to
other processes until deadlock is broken
- issues to be considered
o SELECTING A VICTIM : minimize cost
o ROLL BACK : return to some safe
state,restart process for that state
o STARVATION : same process may always be
picked as victim,include a number of rollback
in cost factor
OS K.Nishitha presentation on dead locks .pptx

OS K.Nishitha presentation on dead locks .pptx

  • 1.
  • 2.
    what is aDEADLOCK? • Deadlock is a situation in which group of processes are blocked. • Each process acquires a resource needed for its completion • Simultaneously the processes waits for the resources to be released by others – thus making impossible for any process to proceed.
  • 3.
    CONDITIONS FOR DEADLOCKTO OCCUR  Mutual Exclusion: At least one resource must be held in a non- sharable mode, meaning only one process can use it at a time.  Hold and Wait: A process must be holding at least one resource is waiting to acquire additional resources held by another processes.  No Preemption: Resources cannot be forcibly taken away from a process; they must be released voluntarily.  Circular Wait: A circular chain of two or more processes exists, where each process is waiting for a resource held by the next process in the chain.
  • 4.
    METHODS FOR HANDLINGDEADLOCKS  Ensure that the system will never enter a deadlock state  Allow the system to enter a deadlock and then recover  Ignore the problem and pretend that deadlock never occurred in the system.This is the simplest and most used in OS.  The first and second methods need techniques to be developed and implemented.These methods are Deadlock Prevention and Deadlock Avoidance.
  • 7.
    DEADLOCK PREVENTION INDIRECT :- preventthe occurrence of Mutual Exclusion, Hold and Wait, No Preemption DIRECT :- prevent the occurrence of Circular Wait
  • 8.
    1. Mutual exclusion– not required for sharable resources,must hold for non sharable resources. 2. Hold and wait – must guarantee that whenever a process request a resource,it does not hold any other resources. 3.No Preemption – can be prevented in many ways. • If a process that is holding some resources requests another resources that cannot be immediately allocated to it,then all resources currently being held are released
  • 9.
    4.Circular wait --impose a total ordering of resources types and require that each process requests resources in an increasing order of enumeration. • Preempted resources are added to the list of resources for which the process is waiting • Process will be restarted only when it can regain its old resources,as well as the new resources that it is requesting
  • 10.
    RECOVERY FROM DEADLOCK 1.PROCESSTERMINATION -> - Abort all deadlock processes -Abort one process at a time until deadlock cycle is eliminated -In partial termination process choosen to abort o Priority of process o How long process has completed and how much longer to completion o Resources process has used o How many resources process need to complete
  • 11.
    2.RESOURCE PREEMPTION -> -successively preempt resources from processes and give it to other processes until deadlock is broken - issues to be considered o SELECTING A VICTIM : minimize cost o ROLL BACK : return to some safe state,restart process for that state o STARVATION : same process may always be picked as victim,include a number of rollback in cost factor