CH 3 Deadlock When 2 (or more) processes remain blocked forever!

Slides:



Advertisements
Similar presentations
Chapter 7: Deadlocks.
Advertisements

Chapter 5 Deadlocks. Contents What is deadlock? What is deadlock? Characterization Characterization Resource allocation graph Resource allocation graph.
ICS Principles of Operating Systems Lectures 8 and 9 - Deadlocks Prof. Dmitri V. Kalashnikov dvk ics.uci.edu Slides © Prof. Nalini Venkatasubramanian.
Deadlock and Starvation
Deadlocks Today Resources & deadlocks Dealing with deadlocks Other issues Next Time Memory management.
6. Deadlocks 6.1 Deadlocks with Reusable and Consumable Resources
MODERN OPERATING SYSTEMS Third Edition ANDREW S
EEE 435 Principles of Operating Systems Deadlock Avoidance, Prevention, and Wrap-Up (Modern Operating Systems 3.5, 3.6, and 3.7)
Chapter 3 Deadlocks TOPICS Resource Deadlocks The ostrich algorithm
MODERN OPERATING SYSTEMS Third Edition ANDREW S. TANENBAUM Chapter 6 Deadlocks Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All.
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.
Deadlock Chapter 3 R1 R2 P2P1 Allocated Requested.
CSC 322 Operating Systems Concepts Lecture - 29: by
Deadlocks Tore Larsen With slides from T. Plagemann, C. Griwodz, K. Li, A. Tanenbaum and M. van Steen.
1 CS 333 Introduction to Operating Systems Class 7 - Deadlock Jonathan Walpole Computer Science Portland State University.
1 Wednesday, June 28, 2006 Command, n.: Statement presented by a human and accepted by a computer in such a manner as to make the human feel that he is.
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
Deadlock CSCI 444/544 Operating Systems Fall 2008.
Chapter 3 Deadlocks 3.1. Resource 3.2. Introduction to deadlocks
Deadlock Characterization
Deadlocks.
Deadlock Chapter 3 Thursday, February 22, Today’s Schedule Assignment #4 from Chapter 3 posted Deadlock - Chapter 3  Skip multiple resources (3.4.2.
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 7 – Deadlock (Pgs 283 – 306). Overview  When a set of processes is prevented from completing because each is preventing the other from accessing.
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.
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.
Deadlocks. What is a Deadlock “A set of processes is deadlocked if each process in the set is waiting for an event that only another process in the set.
Chapter 7: Deadlocks. 7.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts - 7 th Edition, Feb 14, 2005 Chapter 7: Deadlocks The Deadlock.
CSC 322 Operating Systems Concepts Lecture - 28: by Ahmed Mumtaz Mustehsan Special Thanks To: Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall,
Chapter 6 Concurrency: Deadlock and Starvation
Deadlocks System Model RAG Deadlock Characterization
CS333 Intro to Operating Systems Jonathan Walpole.
Chapter 8 Deadlocks. Objective System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance Deadlock Detection.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 6: Deadlocks.
Silberschatz, Galvin and Gagne ©2009 Edited by Khoury, 2015 Operating System Concepts – 9 th Edition, Chapter 7: Deadlocks.
CH 3 Deadlock When 2 (or more) processes remain blocked forever!
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.
Deadlock. Examples You can't get a job without experience; you can't get experience without a job. A set of blocked processes each holding a resource.
Sistem Operasi IKH311 Deadlock. 2 Resources Examples of computer resources printers tape drives tables Processes need access to resources in reasonable.
Deadlocks Lots of resources can only be used by one process at a time. Exclusive access is needed. Suppose process A needs R1 + R2 and B needs R1 + R2.
Operating Systems Chapter 3: Deadlocks
MODERN OPERATING SYSTEMS Third Edition ANDREW S
Deadlocks References text: Tanenbaum ch.3.
Operating System: DEADLOCKS
Process Deadlocks.
Deadlocks References text: Tanenbaum ch.3.
CS 333 Introduction to Operating Systems Class 7 - Deadlock
DPNM Lab. Dept. of CSE, POSTECH
MODERN OPERATING SYSTEMS Third Edition ANDREW S
Chapter 3 Deadlocks 3.1. Resource 3.2. Introduction to deadlocks
DEADLOCK.
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.
MODERN OPERATING SYSTEMS Third Edition ANDREW S
Presentation transcript:

CH 3 Deadlock When 2 (or more) processes remain blocked forever!

How can this happen? Process a –Down x –Gets x –Down y –Blocks Process b –Down y –Gets y –Down x –Blocks Both are blocked forever!

Resources Things for which we request exclusive access. –Ex. db, files, shared memory, printer, cd/dvd writer, tape drive, etc. Types 1.Preemptable – can be taken away w/out ill effects 2.Non preemptable – cannot be take away w/out causing a failure

Resource examples Memory – preemptable CPU – preemptable CD writing – non preemptable Printing – non preemptable We will only consider non preemptable (the harder problem).

Deadlock 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.

Conditions for deadlock 1.Mutual exclusion 2.Hold and wait 3.No preemption 4.Circular wait (Need all of these (all necessary).)

Resource allocation graph process resource

(Directed) Graphs A graph G = (V,E) where V = vertex set and E = edge set Ordered pairs of vertices Ex. Let G = (V,E) where V = { C, D, T, U } and E = {,,, }

Dealing w/ deadlock 1.Ignore it (ostrich algorithm). 2.Detect and recover. 3.Avoid by careful resource allocation. 4.Disallow one or more of the conditions necessary for deadlock.

2. Detect and recover Detection with one resource of each type Detection with multiple resources of each type

Detection with one resource of each type Detect cycle in digraph –For each vertex v in graph, search the subtree rooted at v see if we visit any vertex twice (by keeping a record of already visited vertices).

Detection with multiple resources of each type Skip.

Recovery 1.Preemption 2.Rollback (using checkpoints) 3.Kill process

Recovery: preemption Temporarily take back needed resource Ex. Printer Pause at end of page k Start printing other job Resume printing original job starting at page k+1

Recovery: rollback Checkpoint – save entire process state (typically right before the resource was allocated) When deadlock is detected, we kill the checkpointed process, freeing the resource, and then later restart the killed process starting at the checkpoint. –Requires apps that can be restarted in this manner.

Rdb’s & commit/rollback From p. 62,

Recovery: kill process Requires apps that can be restarted from the beginning.

Deadlock avoidance Safe state = not deadlocked and there exists some scheduling order in which every process can run to completion even if all of them suddenly request their max number of resources immediately Unsafe != deadlocked

Safe states

Unsafe states

Banker’s algorithm (for single resource type) Grant only those requests that lead to safe states. Requires future information.

Banker’s algorithm (b) is safe because from (b) we can give C 2 more (free=0) then C completes (free=4) then give either B or D...

Banker’s algorithm (c) is unsafe because no max can be satified

Banker’s algorithm (multiple resources) ∑ N: E=existing (free) P=possessed (allocated/held) A=available

Banker’s algorithm (multiple resources) To check for a safe state: 1.Look for a row, R, in N <= A. 2.Assume the process of the chosen row requests all resources, runs to completion, and terminates (giving back all of its resources to A). 3.Repeat steps 1 and 2 until either all processes either terminate (indicating that the initial state was safe) or deadlock occurs.

Banker’s algorithm (multiple resources) To check for a safe state: 1.Look for a row, R, in N <= A.

Deadlock prevention Attack: –Mutual exclusion –Hold and wait –No preemption –Circular wait

Deadlock prevention: attack mutex Ex. Use spooling instead of mutex on printer No all problems lend themselves to spooling Still have contention for disk space with spooling

Deadlock prevention: attack hold & wait Request (wait for) all resources prior to process execution –Problems: We may not know a priori. We tie up resources for entire time. Before requesting a resource, we must first temporarily release all allocated resources and then try to acquire all of them again.

Deadlock prevention: attack no preemption Tricky at best. Impossible at worst.

Deadlock prevention: attack circular wait 1.Only allow one resource at a time. 2.Request all resources in (some globally assigned) numerical order. No numerical ordering may exist.