Your SlideShare is downloading. ×
23 deadlock
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

23 deadlock

525

Published on

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
525
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
14
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Understand Process Management• Deadlocks 1
  • 2. •HOME PREVIOUS TOPICNEXT•PREVIOUS QUESTION PAPERSFOR OS•CPP TUTORIALS 2
  • 3. RecapIn the last class, you have learnt• Semaphore• IPC
  • 4. Objectives On completion of this class, you would be able to know:• Definition Dead Lock• Necessary conditions for the occurrence of Dead lock• Resource Allocation Graph• Resource Allocation Graph with a Deadlock 4
  • 5. Deadlocks•In a multiprogramming environment, several processesmay compete for a finite number of resources•A process requests resources, if the resources are notavailable at that time, the process enters a wait state• Some times a waiting process may never again able tochange state, because the resources they have requestedare held by other waiting processes•This situation is called “Deadlock” 5
  • 6. Deadlock• A set of process is in a deadlock state, – when every process in the set is waiting far an event, – that can be caused only by another process in the set• The resources can be either Physical resources – like prints, tape drives, memory space, and CPU cycles or Logical resources – like files, semaphores and monitors 6
  • 7. DeadlockExample:• Consider a system with one printer and one DVD drive• Suppose that process Pi is holding the DVD and process Pj is holding the printer• If Pi requests the printer and Pj requests the DVD drive, a deadlock occurs 7
  • 8. Necessary Conditions for Deadlock1. Mutual exclusion2. Hold and wait3. No Preemption4. Circular wait 8
  • 9. Necessary Conditions for DeadlockMutual exclusion•At least one resource must be held in a non-sharable mode•The requesting process must be delayed until the resource has been released 9
  • 10. Necessary Conditions for DeadlockHold and wait•A process must exist that is holding at least one resource•The process is waiting to acquire additional resources which are currently being held by other processes 10
  • 11. Necessary Conditions for DeadlockNo preemption• Resources cannot be preempted• A resource can be released only voluntarily by the process holding it 11
  • 12. Necessary Conditions for DeadlockCircular wait• A set{P0,P1,…. ,Pn} of waiting processes must exist such that• P0 is waiting for resource held by P1• P1 is waiting for resource held by P2• Pn-1 is waiting for resource held by Pn• Pn is waiting for resource held by P0 12
  • 13. Resource Allocation Graph• Deadlocks can be described more precisely in terms of a directed graph called a system resource – allocation graph• This graph consists of a set of vertices V and set of edges E• The set of vertices V is partitioned into two different types of nodes: P = { P1,P2,----, Pn} – the set consisting of all the active process in the system R = { R1,R2,----,Rm} - the set consisting of all resource types in the system 13
  • 14. Resource Allocation Graph• Pi Rj – Signifies that process Pi has requested an instance of resource type Rj and is currently waiting for that resource – request edge• Rj Pi - signifies that an instance of resource type Rj has been allocated to process Pi – assignment edge• Each process Pi is represented by a circle• Each resource type Rj is represented by a rectangle 14
  • 15. Resource Allocation GraphThe resource allocation graph depicts the following situationThe sets P,R,E:• P={P1,P2,P3}• R={R1,R2,R3,R4}• E={P1 R1, P2 R3, R1 P2, R2 P2, R2 P1, R3 P3} 15
  • 16. Resource Instances• One instance of resource type R1• Two instances of resource type R2• One instance of resource type R3• Three instances of resource type R4 16
  • 17. Process States• Process P1 is holding an instance of resource R2 and is waiting for R1• Process P2 is holding an instance of R1 and R2 and is waiting for R3• Process P3 is holding an instance of R3 17
  • 18. Resource Allocation Graph R1 R3P1 P2 P3 R2 Fig 1 R4 18
  • 19. Resource Allocation Graph
  • 20. Resource Allocation• Suppose P3 requests R2• At this point two minimal cycles exist in the system :• P1 R1 P2 R3 P3 R2 P1• P2 R3 P3 R2 P2• Process P1, P2 and P3 are Deadlocked 20
  • 21. Resource – Allocation Graph with a Deadlock R1 R3 P1 P2 P3 R2 Fig 2 R4 21
  • 22. Resource – Allocation• There is a cycle P1 R1 P3 P1• But there is no deadlock• If a resource-allocation graph does not have a cycle, then the system is not in a deadlocked state• If there is a cycle, then the system may Fig 2 or may not be in a deadlocked state 22
  • 23. Summary In this class, you have learnt :• Deadlock• The necessary conditions for a deadlock to occur namely• Mutual exclusion• Hold and wait• No preemption• Circular wait• Resource allocation graphs 23
  • 24. Frequently Asked Questions1. Explain the necessary conditions that should exist in a system for a deadlock to occur2. Explain about resource-allocation graphs 24
  • 25. Quiz1. Characteristics of deadlock a) No Hold and wait b) Circular wait c) Preemption d) All of the above2. Deadlock occurrence a)In sharable mode b)In non-sharable mode 25
  • 26. Other subject materials• Web designing• Micro processors• C++ tutorials• javahome
  • 27. Quiz3. A directed edge Pi--Rj is called a ------- a) Request edge4. Deadlocks can be described in terms of ------- a)Resource - allocation5. A directed edge Rj --- Pi is called an--- a) Assignment edge 27

×