Deadlock Chapter 3 Thursday, February 22, 2007. Today’s Schedule Assignment #4 from Chapter 3 posted Deadlock - Chapter 3  Skip multiple resources (3.4.2.

Slides:



Advertisements
Similar presentations
Understanding Operating Systems Fifth Edition Chapter 5 Process Management.
Advertisements

Deadlocks Today Resources & deadlocks Dealing with deadlocks Other issues Next Time Memory management.
MODERN OPERATING SYSTEMS Third Edition ANDREW S
Ceng Operating Systems Chapter 2.4 : Deadlocks Process concept  Process scheduling  Interprocess communication  Deadlocks Threads.
Chapter 3 Deadlocks TOPICS Resource Deadlocks The ostrich algorithm
1 Deadlocks Chapter Resource 3.2. Introduction to deadlocks 3.3. The ostrich algorithm 3.4. Deadlock detection and recovery 3.5. Deadlock avoidance.
5/25/2015Page 1 Deadlock Management B. Ramamurthy.
Chapter 3 Deadlocks - Αδιέξοδα 3.1. Resource
With slides from C. Griwodz, K. Li, A. Tanenbaum and M. van Steen
Avishai Wool lecture Introduction to Systems Programming Lecture 5 Deadlocks.
DPNM Lab. Dept. of CSE, POSTECH
Deadlock Chapter 3 R1 R2 P2P1 Allocated Requested.
Deadlocks Tore Larsen With slides from T. Plagemann, C. Griwodz, K. Li, A. Tanenbaum and M. van Steen.
Mehdi Naghavi Spring 1386 Operating Systems Mehdi Naghavi Spring 1386.
Chapter 3: Deadlocks Chapter 3 2 CMPS 111, UC Santa Cruz Overview  Resources  Why do deadlocks occur?  Dealing with deadlocks Ignoring them: ostrich.
Deadlocks. 2 System Model There are non-shared computer resources –Maybe more than one instance –Printers, Semaphores, Tape drives, CPU Processes need.
The Banker’s Algorithm for A Single Resource
Chapter 7: Deadlocks. 7.2 Chapter Objectives To develop a description of deadlocks, which prevent sets of concurrent processes from completing their tasks.
Deadlock CSCI 444/544 Operating Systems Fall 2008.
Chapter 3 Deadlocks 3.1. Resource 3.2. Introduction to deadlocks
Chapter 5 : Process Management
Understanding Operating Systems Sixth Edition
CS450/550 Deadlocks.1 Adapted from MOS2E UC. Colorado Springs CS450/550 Operating Systems Lecture 3 Deadlocks Palden Lama Department of Computer Science.
Chapter 3 Chapter 3: Deadlocks Chapter 3 2 CS 1550, cs.pitt.edu (originaly modified by Ethan L. Miller and Scott A. Brandt) Overview Resources Why do.
Chapter 5 Process Management Understanding Operating Systems, Fourth Edition.
CH 3 Deadlock When 2 (or more) processes remain blocked forever!
1 Deadlocks Chapter Resource 3.2. Introduction to deadlocks 3.3. The ostrich algorithm 3.4. Deadlock detection and recovery 3.5. Deadlock avoidance.
Chapter 3: Deadlocks. CMPS 111, Fall Overview ✦ Resources ✦ Why do deadlocks occur? ✦ Dealing with deadlocks Ignoring them: ostrich algorithm Detecting.
Chapter 7 – Deadlock (Pgs 283 – 306). Overview  When a set of processes is prevented from completing because each is preventing the other from accessing.
Overview Resources Why do deadlocks occur? Dealing with deadlocks Ignoring them: ostrich algorithm Detecting & recovering from deadlock Avoiding deadlock.
1 Deadlocks Chapter Resource 3.2. Introduction to deadlocks 3.4. Deadlock detection and recovery 3.5. Deadlock avoidance 3.6. Deadlock prevention.
1 Deadlocks 2 Resources Examples of computer resources –printers –tape drives –tables Processes need access to resources in reasonable order Suppose.
1 Deadlocks Chapter Resource 3.2. Introduction to deadlocks 3.3. The ostrich algorithm 3.4. Deadlock detection and recovery 3.5. Deadlock avoidance.
1 Deadlocks Chapter 3. 2 Resources Examples of computer resources –printers –tape drives –tables Processes need access to resources in reasonable order.
Operating Systems 软件学院 高海昌 Operating Systems Gao Haichang, Software School, Xidian University 22 Contents  1. Introduction** 
Operating Systems Part III: Process Management (Deadlocks)
1 Deadlock Definition of deadlock Condition for its occurrence Solutions for avoiding and breaking deadlock –Deadlock Prevention –Deadlock Avoidance –Deadlock.
1 Deadlocks Chapter Resource 3.2. Introduction to deadlocks 3.3. The ostrich algorithm 3.4. Deadlock detection and recovery 3.5. Deadlock avoidance.
Operating Systems (OS)
1 MODERN OPERATING SYSTEMS Third Edition ANDREW S. TANENBAUM Chapter 6 Deadlocks Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc.
MODERN OPERATING SYSTEMS Third Edition ANDREW S. TANENBAUM Chapter 6 Deadlocks Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All.
Process Synchronization
CS 346 – Chapter 7 Deadlock –Properties –Analysis: directed graph Handle –Prevent –Avoid Safe states and the Banker’s algorithm –Detect –Recover.
Deadlocks System Model RAG Deadlock Characterization
CS333 Intro to Operating Systems Jonathan Walpole.
Chapter 5 Process Management Semester 2. Objectives  What is a deadlock?  Seven cases of deadlocks  Conditions of deadlocks –Mutual exclusion.
CH 3 Deadlock When 2 (or more) processes remain blocked forever!
Copyright ©: Nahrstedt, Angrave, Abdelzaher1 Deadlock.
Deadlocks References –text: Tanenbaum ch.3. Deadly Embrace Deadlock definition –A set of process is dead locked if each process in the set is waiting.
Sistem Operasi IKH311 Deadlock. 2 Resources Examples of computer resources printers tape drives tables Processes need access to resources in reasonable.
Operating Systems Chapter 3: Deadlocks
Chapter 5 - Process Management
Deadlock Management.
Chapter 5 Process Management
Chapter 6 : Deadlocks What is a Deadlock?
Deadlocks References text: Tanenbaum ch.3.
Lecture 19: Deadlock: Conditions, Detection and Avoidance
Chapter 7: Deadlocks.
Deadlocks References text: Tanenbaum ch.3.
Chapter 3 Deadlocks 3.1. Resource 3.2. Introduction to deadlocks
DPNM Lab. Dept. of CSE, POSTECH
MODERN OPERATING SYSTEMS Third Edition ANDREW S
Chapter 3 Deadlocks 3.1. Resource 3.2. Introduction to deadlocks
Deadlocks Session - 13.
Lecture 19: Deadlock: Conditions, Detection and Avoidance
Chapter 3 Deadlocks 3.1. Resource 3.2. Introduction to deadlocks
Introduction to Deadlocks
Chapter 3 Deadlocks 3.1. Resource 3.2. Introduction to deadlocks
Deadlocks References text: Tanenbaum ch.3.
Deadlock CSE 2431: Introduction to Operating Systems
Presentation transcript:

Deadlock Chapter 3 Thursday, February 22, 2007

Today’s Schedule Assignment #4 from Chapter 3 posted Deadlock - Chapter 3  Skip multiple resources (3.4.2 & 3.5.4)

Today’s Objectives You will be able to describe: Several causes of system deadlock The difference between preventing and avoiding deadlocks How to detect and recover from deadlocks How to prevent deadlock

Overview A lack of process synchronization results in deadlock or starvation  Deadlock: A system-wide tangle of resource requests that begins when two or more jobs are put on hold Each job waiting for a vital resource to become available The jobs come to a standstill Resolved via external intervention  Starvation: Infinite postponement of a job

Starvation Which of the following scheduling algorithms could result in starvation? If so, how? First-come, First-served Shortest job first Round robin Priority

Deadlock Affects more than one job, hence more serious than starvation System (not just a few programs) is affected as resources are being tied up  e.g., Traffic jam

Deadlock in Spooling Virtual device: Sharable device—e.g., a printer transformed by installing a high-speed device, a disk, between it and the CPU Spooling: Disk accepts output from several users and acts as a temporary storage area for all output until printer is ready to accept it Deadlock in spooling: If printer needs all of a job's output before it will begin printing, but spooling system fills available disk space with only partially completed output

Deadlock Defined From our more playful days …  I’ve got the ball and want the bat  You’ve got the bat and want the ball “A set of processes is deadlocked if each process in the set is waiting for an event that only another process in the set can cause.”

Modeling Deadlocks Resource Allocation Graphs Process P1 holds Resource R1 Process P1 requests Resource R1

A B C How deadlock occurs Cycle formed!!

How deadlock can be avoided (o) (p) (q)

Conditions Required for Deadlock 1.Mutual exclusion condition each resource assigned to 1 process or is available 2.Hold and wait condition process holding resources can request additional 3.No preemption condition previously granted resources cannot forcibly taken away 4.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

Dealing with Deadlock Ostrich Algorithm Ignore deadlock possibility! Detection & Recovery Dynamic Avoidance  careful resource allocation Prevention  negating one of the four necessary conditions

Ostrich Algorithm Stick your head in the sand and pretend there is no problem at all Reasonable if  deadlocks occur very rarely  cost of prevention is high UNIX and Windows takes this approach Trade off between  convenience  correctness What is the typical use of the system?  What is the probability of deadlock?  Do the costs associated with dealing w/ deadlock outweigh the benefits?

Detecting Deadlock – Find Cycle Note the resource ownership and requests A cycle can be found within the graph, denoting deadlock

How to Recover from Deadlock? Recovery through preemption  take a resource from some other process  depends on nature of the resource Recovery through rollback  checkpoint a process periodically  use this saved state  restart the process if it is found deadlocked Recovery through killing processes  crudest but simplest way to break a deadlock  kill one of the processes in the deadlock cycle

Avoid Deadlock Resource Trajectories Show I1I1 I2I2 I3I3 I5I5 I4I4 I6I6 I8I8 I7I7 I9I9 Printer Plotter Printer Plotter pq s r t u A B Impossible Unsafe

Safe/Unsafe States Safe State  Not in deadlock  There is some scheduling order with which all processes can finish Unsafe State  Not necessarily deadlock  Doesn’t guarantee deadlock  But can’t guarantee deadlock will be avoided

Avoid Deadlock Safe State Unsafe State deadlock

Banker’s Algorithm – Avoid Deadlock Regulate resource allocation  No loan exceeding bank’s total capital  Customers have a pre-set maximum credit  May not borrow over the limit  Total of all loans may not exceed bank’s capital

Avoidance (continued) The bank started with $10,000 and has remaining capital of $4,000 after these loans Safe state: Bank still has enough money left after loans to satisfy the maximum requests of C1, C2, or C3

Avoidance (continued) Table 5.5: The bank has remaining capital of only $1,000 after these loans and therefore is in an “unsafe state” Unsafe state: Bank does not have enough money left after loans to satisfy the maximum requests of C1, C2, or C3

Avoidance (continued) Table 5.6: A safe state: six devices are allocated and four units are still available Same banking principles can be applied to an operating system

Avoidance (continued) An unsafe state: only one unit is available but every job requires at least two to complete its execution

Deadlock Avoidance To avoid deadlock, OS must make sure:  Never satisfy a request that moves it from a safe state to an unsafe one  Must identify the job with the smallest number of remaining resources  Number of available resources is always equal to, or greater than, the number needed for the selected job to run to completion

Attack Deadlock Conditions Attack Mutual Exclusion Attack Hold and Wait  Require all process to request all resources before starting execution  Resource must temporarily release all the resources it currently holds Attack No preemption  Just take away resource, does not work Attack Circular Wait condition  Process is entitled to single resource at any moment  Use of global numbering All requests made in numerical order

Summary Resources can be preemptable & nonpreemptable Deadlock can cause processes to halt (stop making progress) We can detect deadlock RAGs are quite useful to detect deadlock Ostrich algorithm quite popular

Summary (cont) Trajectories can help in process scheduling to avoid deadlock Avoid unsafe states Prevent Deadlock by attack one of four necessary conditions Ordering resources avoids circular wait Keep processes from starving – all processes must make some progress

Tuesday, Feb 27, Memory Complete Assignment #4 Begin reading Chapter 4 – Memory Management