Deadlock ppt

29,480 views

Published on

0 Comments
38 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
29,480
On SlideShare
0
From Embeds
0
Number of Embeds
14
Actions
Shares
0
Downloads
1,959
Comments
0
Likes
38
Embeds 0
No embeds

No notes for slide

Deadlock ppt

  1. 1. DEADLOCKA process request the resources,the resources are not available atthat time, so the process enterinto the waiting state. Therequesting resources are held byanother waiting process, both arein waiting state, this situation is
  2. 2. CONDITIONS FORDEADLOCK
  3. 3. A Deadlocked system must satisfied thefollowing 4 conditions. These are :1. MUTUAL EXCLUSION2. HOLD AND WAIT3. NO PREEMPTION4. CIRCULAR WAIT
  4. 4. DeadlockAviodence
  5. 5. Avoid actions that may lead to a deadlock.Think of it as a state machine moving from 1state to another as each instruction isexecuted.We can avoid the situattion of deadlockedby: 1.Safe State 2.Banker‟s Algorithm 3.Resource Allocation Graph
  6. 6. Safe StateSafe state is one where : It is not a deadlockedstate There is some sequence by which allrequests can be satisfied.To avoid deadlocks, we try to make only thosetransitions that will take you from one safestate to another. We avoid transitions tounsafe state (a state that is not deadlocked,and is not safe)
  7. 7. Unsafe Deadlock SafeSafe unsafe and deadlock state spaces
  8. 8. Bankers AlgorithmWhen a request is made, check to see if afterthe request is satisfied, there is a (atleast one!)sequence of moves that can satisfy all therequests ie. the new state is safe. If so,satisfy the request, else make the requestwait.
  9. 9. Resource Allocation GraphIf we have a resource allocationsystem with only one inatance of eachprocess, a varient of the resourceallocation graph can be used fordeadlock avoidence.
  10. 10. R2 R1 P3P1 P2 R3 R4 Resource Allocation Graph
  11. 11. DEADLOCKPREVENTIONS
  12. 12. Difference from avoidance is that here, thesystem itself is build in such a way thatthere are no deadlocks.Make sure atleast one of the 4 deadlockconditions is never satisfied.This may however be even more conservativethan deadlock avoidance strategy.
  13. 13. MUTUAL EXCLUSION: We can deny this condition by simple protocol i.e., “convert the all non-sharable resources to sharable resources”. HOLD AND WAIT : We can deny this condition withCIRCULAR WAIT : We ensure following two protocols : that circular wait must not happened if we apply a simple “A process request the solution, i.e., numbering all the resources only when the resources types and each process process has none”.request resources in an increasing order of enumeration • “Each process to request and be allocated all its resources before it begins execution”. NO PREEMPTION :To ensure that this condition does not hold, we use the following protocol : we preempt the desired resources from the waiting process and allocate them to the requesting process.
  14. 14. DeadlockDetection
  15. 15. Detection mechanism of deadlocks for single instanceof resource type is different. We can detect the deadlocks using wait for graph for single instance resourcetype and detect using detection algorithm for multipleinstances of resource type.1.SINGLE INSTANCE OF RESOURCE TYPE : Single instance of resource type means, the system consisting of only one resource for one type. We can detect this type of deadlocks with the help of wait for graph.
  16. 16. P1 R1 P2 P2 R2 P3 P2 P3 P1 P2 R3 P1 P3 R4 P2 Wait for graph A system is in deadlock state , if and only if the wait for graphcontains cycles. So we can detect the deadlocks with cycles. In thefigure there is 2 cycles one is P1 to P2 to P1, second one P2 to P3 to P2so the system consisting of deadlocks.
  17. 17. 2. SEVERAL INSTANCE OF RESOURCE TYPEThe wait for graph is not applicable to severalinstance of resource type. So we need anothermethod for this type, that is “deadlock detectionalgorithm”. This algorithm looks like „Banker‟salgorithm” and it employees several datastructures that are similar to those used in theBanker‟s algorithm.
  18. 18. Deadlockrecovery
  19. 19. Once deadlock has been detected, some strategyis needed for recovery. The various approachesof recovering from deadlock are:  PROCESS TERMINATION RESOURCE PREEMPTION
  20. 20. PROCESS TERMINATION “Process termination” it is one method to recover from deadlock. We uses 2 methods for process termination, these are:a) ABORT ALL DEADLOCKED PROCESS : It means release all the processes in the deadlocked state, and start the allocation from the starting point. It is a great expensive method.b) ABORT ONE BY ONE PROCESS UNTIL THE DEADLOCK CYCLE IS ELIMINATED : In this method first abort the one of the processes in the deadlocked state, and allocated the resources to some other process in the deadlock
  21. 21. RESOURCE PREEMPTIONTo eliminate deadlocks using resource preemption, preempt some resourcesfrom processes and give these resources to otherprocesses until the deadlock cycle is broken.There are 3 methods to eliminate the deadlocks usingresource preemption.These are :a) SELECTING A VICTIM : Select a victim resource from the deadlock state, and preempt that one.b) ROLLBACK : If a resource from a process is preempted, what should be done with that process. The process must be roll backed to some safe state and restart it from that state.c) STARVATION : It must be guaranteed that

×