Lecture 18: Deadlock: Conditions, Detection and Avoidance (cont.)

Slides:



Advertisements
Similar presentations
Chapter 7: Deadlocks.
Advertisements

Deadlock Prevention, Avoidance, and Detection
Deadlock Prevention, Avoidance, and Detection.  The Deadlock problem The Deadlock problem  Conditions for deadlocks Conditions for deadlocks  Graph-theoretic.
MODERN OPERATING SYSTEMS Third Edition ANDREW S
7.5 Deadlock Avoidance The algorithm is simply to ensure that the system will always remain in safe state. Therefore, if a process requests a resource.
Operating Systems COMP 4850/CISG 5550 Deadlock Avoidance Dr. James Money.
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.
Tanenbaum Ch 6 Silberschatz Ch 7
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.
1 CS 333 Introduction to Operating Systems Class 7 - Deadlock Jonathan Walpole Computer Science Portland State University.
Chapter 3 Deadlocks 3.1. Resource 3.2. Introduction to deadlocks
Deadlock Detection with One Resource of Each Type (1)
Chapter 7: Deadlocks. 7.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Bridge Crossing Example Traffic only in one direction. Each section.
Chapter 6 Deadlocks Resources Introduction Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved
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 Processes, Threads, Race Conditions & Deadlocks Operating Systems Review.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Deadlocks.
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 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** 
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.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 28 Handling Deadlock.
MODERN OPERATING SYSTEMS Third Edition ANDREW S. TANENBAUM Chapter 6 Deadlocks Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All.
CSC 322 Operating Systems Concepts Lecture - 28: by Ahmed Mumtaz Mustehsan Special Thanks To: Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall,
CS333 Intro to Operating Systems Jonathan Walpole.
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.
Deadlocks CPE Operating Systems
Deadlocks Chapter 6 Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
7: Deadlocks1 OPERATING SYSTEMS DEADLOCKS. 7: Deadlocks2 What Is In This Chapter? What is a deadlock? Staying Safe: Preventing and Avoiding Deadlocks.
Lecture 6 Deadlock 1. Deadlock and Starvation Let S and Q be two semaphores initialized to 1 P 0 P 1 wait (S); wait (Q); wait (Q); wait (S);. signal (S);
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.
CSSE 332 Operating Systems Rose-Hulman Institute of Technology
FAA FAA (int s, int val) { temp = s; s = s + val; return temp; }
Operating Systems, Summer Semester 2011
Operating Systems, Winter Semester 2011
MODERN OPERATING SYSTEMS Third Edition ANDREW S
Chapter 6 : Deadlocks What is a Deadlock?
Deadlocks References text: Tanenbaum ch.3.
OPERATING SYSTEMS DEADLOCKS
Lecture 19: Deadlock: Conditions, Detection and Avoidance
Chapter 7 Deadlocks.
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 27 Syed Mansoor Sarwar
Lecture 19: Deadlock: Conditions, Detection and Avoidance
Chapter 3 Deadlocks 3.1. Resource 3.2. Introduction to deadlocks
IT3002 Computer Architecture
OPERATING SYSTEMS DEADLOCKS.
DEADLOCKS.
Introduction to Deadlocks
Chapter 3 Deadlocks 3.1. Resource 3.2. Introduction to deadlocks
Deadlocks References text: Tanenbaum ch.3.
Chapter 8: Deadlocks Deadlock Characterization
MODERN OPERATING SYSTEMS Third Edition ANDREW S
Presentation transcript:

Lecture 18: Deadlock: Conditions, Detection and Avoidance (cont.)

Review: 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

In this lecture Strategies for dealing with Deadlocks just ignore the problem altogether detection and recovery dynamic avoidance careful resource allocation prevention negating one of the four necessary conditions

Ignore the problem

Deadlock Detection Suppose you were given The resources currently held by each The additional resources each process wants Question: Is the system deadlocked?

Deadlock Detection One resource of each type Multiple resources of each type

Detection with One Resource of Each Type Note the resource ownership and requests A cycle can be found within the graph, denoting deadlock

Detection with multiple Resources of Each Type Is there some order of execution of the processes which allows all of them to complete? If yes, then not deadlocked If no such order exists, then deadlocked After each process finishes, it releases resources back to the system

Example 1 Process Resources Held Resources Needed P1 A=1, B=1 1 of B B=1, C=1 1 of C P3 C=1, A=1 none Resource Type Copies A 2 B C Not deadlocked, since P3 can run, releasing resources for P2, which releases resources to P1 upon finishing

Example 2 Process Resources Held Resources Needed P1 A=1, B=1 1 of B B=1, C=1 1 of C P3 C=1, A=1 1 of A Resource Type Copies A 2 B C Deadlocked, since nobody can make progress

Example 3 Process Resources Held Resources Needed P1 A=1, B=1 1 of B B=1, C=1 2 of A P3 C=1, A=1 None Resource Type Copies A 2 B C Deadlocked: Let P3 complete. P3 releases resources. But then, nobody else can proceed.

Detection with Multiple Resources of Each Type (1) Data structures needed by deadlock detection algorithm

Detection with Multiple Resources of Each Type (2) Look for an unmarked process, P_i, for which the ith row of R is less than or equal to A. If such a process is found, add the ith row of C to A, mark the process, and go back to 1 If no such process exists, the algorithm terminates.

Detection with Multiple Resources of Each Type (3) An example for the deadlock detection algorithm

Recovery from Deadlock Recovery through Preemption Recovery through Rollback Recover through Killing-process