lecture 7 deadlock

50 %
50 %
Information about lecture 7 deadlock

Published on September 17, 2007

Author: Techy_Guy

Source: authorstream.com

Deadlocks:  Deadlocks Chapter 3 TOPICS Resource Deadlocks The ostrich algorithm Deadlock detection and recovery Deadlock prevention Deadlock avoidance Reference: Operating Systems Design and Implementation (Second Edition) by Andrew S. Tanenbaum, Albert S. Woodhull Resources(1):  Resources(1) Examples of computer resources printers tape drives Tables Resources (2):  Resources (2) Deadlocks occur when … processes are granted exclusive access to devices we refer to these devices generally as resources Preemptable resources can be taken away from a process with no ill effects Example: process swapping form main memory Nonpreemptable resources will cause the process to fail if taken away Example: print request by more than one proceses Resources (3):  Resources (3) Sequence of events required to use a resource request the resource use the resource release the resource Must wait if request is denied requesting process may be blocked may fail with error code Deadlocks:  Deadlocks Suppose a process holds resource A and requests resource B at same time another process holds B and requests A both are blocked and remain so Deadlock Modeling:  Deadlock Modeling Modeled with directed graphs resource R assigned to process A process B is requesting/waiting for resource S process C and D are in deadlock over resources T and U Four Conditions for Deadlock:  Four Conditions for Deadlock Four conditions must hold for there to be a deadlock: Mutual exclusion condition each resource assigned to 1 process or is available Hold and wait condition process holding resources can request additional No preemption condition previously granted resources cannot forcibly taken away Circular wait condition must be a circular chain of 2 or more processes each is waiting for resource held by next member of the chain How deadlock occurs:  A B C How deadlock occurs How deadlock can be avoided:  How deadlock can be avoided (o) (p) (q) Strategy to Deal with Deadlock:  Strategy to Deal with Deadlock Strategies for dealing with Deadlocks Just ignore the problem altogether Detection and recovery Prevention Negating one of the four necessary conditions of deadlock Dynamic avoidance Careful resource allocation Strategy 1: The Ostrich Algorithm:  Strategy 1: The Ostrich Algorithm Just ignore the problem Reasonable if deadlocks occur very rarely cost of prevention is high UNIX and Windows takes this approach It is a trade off between convenience correctness Strategy 2: Detection and Recovery:  Strategy 2: Detection and Recovery Method 1: Every time a resource is requested or released, the resource graph is updated, and a check is made to see if any cycle exist. If a cycle exists, one of the process is the cycle is killed. If this does not break the deadlock, another process is killed and so on until the cycle is broken Method2 Periodically check to see if there are any processes that have been continuously blocked for more than say 1 hour. Such processes are then killed Strategy 3: Deadlock Preventiona) Attacking the Mutual Exclusion Condition:  Strategy 3: Deadlock Prevention a) Attacking the Mutual Exclusion Condition Some devices (such as printer) can be spooled only the printer daemon uses printer resource thus deadlock for printer eliminated Not all devices can be spooled b) Attacking the Hold and Wait Condition:  b) Attacking the Hold and Wait Condition Require processes to request resources before starting A process is allowed to run if all resources it needed is available. Otherwise it will just wait. Problems May not know required resources at start of run Resource will not be used optimally Variation: process must give up all resources and then request all immediately needed c) Attacking the No Preemption Condition:  c) Attacking the No Preemption Condition This is not a viable option Consider a process given the printer halfway through its job now forcibly take away printer !!?? d) Attacking the Circular Wait Condition:  d) Attacking the Circular Wait Condition Numerically ordered resources Resource Graph A process may request 1st a printer, then tape dirve. But it may not request 1st a plotter, then a scanner. Resource graph can never have cycle. Deadlock Prevention Summary:  Deadlock Prevention Summary Strategy 4: Deadlock Avoidance:  Strategy 4: Deadlock Avoidance Carefully analyze each resource request to see if it can be safely granted. Need an algorithm that can always avoid deadlock by making right choice all the time. Banker’s algorithm (by Dijkstra) Deadlock AvoidanceResource Trajectories:  Deadlock Avoidance Resource Trajectories Two process resource trajectories Safe and Unsafe States (1):  Safe and Unsafe States (1) Demonstration that the state in (a) is safe (a) (b) (c) (d) (e) Safe and Unsafe States (2):  Safe and Unsafe States (2) (a) (b) (c) (d) unsafe safe safe safe The Banker's Algorithm for a Single Resource:  The Banker's Algorithm for a Single Resource Three resource allocation states (a) (b) (c) safe safe unsafe Banker's Algorithm for Multiple Resources:  Banker's Algorithm for Multiple Resources Example of banker's algorithm with multiple resources

Add a comment

Related presentations

Related pages

Lecture 7: Deadlock - Freie Universität

Concurrent Programming 19530-V (WS0119530-V (WS01) Lecture 7: Deadlock Dr. Richard S. Hall rickhall@inf.fu-berlin.de Concurrent programming – December 4 ...
Read more

Lecture 7: Deadlock

C SC 340 Lecture 7: Deadlock [ previous | schedule | next] additional resource: Modern Operating Systems (2nd Ed), Tanenbaum, Prentice Hall, 2001.
Read more

Lecture 7: Deadlock | CS2106

30 September, 2011 This week we will look at deadlock in more details, as well as other nuisances caused by buggy synchronization code, including livelock ...
Read more

Lecture 7 Deadlock - NUS Computing

while (1) think wait till left chopstick is available pick up left chopstick wait till right chopstick is available pick up right chopstick eat put down ...
Read more


Deadlock INF2140Modelingandprogrammingparallelsystems Lecture7 March06,2013 INF2140 Modeling and programming parallel systems Lecture 7 Deadlock
Read more

COP 5611 L07 - Computer Science, FSU

Lecture #7: Deadlock. These topics are from Chapters 3 ... communication deadlock: each process is waiting for communication from another process, ...
Read more

Deadlocks - Computer Science & Engineering

Lecture 13 Chapter 7: Deadlocks * * * Chapter 7: Deadlocks The Deadlock Problem System Model Deadlock Characterization Methods for Handling Deadlocks ...
Read more

Lecture 12: Deadlocks (Chapter 7)

Operating System Concepts – 8 th Edition, Silberschatz, Galvin and Gagne ©2009 Lecture 12: Deadlocks (Chapter 7)
Read more


7: Deadlocks 4 • Traffic only in one direction. • Each section of a bridge can be viewed as a resource. • If a deadlock occurs, it can be resolved if ...
Read more