Deadlocks.

Slides:



Advertisements
Similar presentations
Chapter 7: Deadlocks.
Advertisements

1 Concurrency: Deadlock and Starvation Chapter 6.
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
Operating Systems Lecture Notes Deadlocks Matthew Dailey Some material © Silberschatz, Galvin, and Gagne, 2002.
Concurrency: Deadlock and Starvation Chapter 6. Deadlock Permanent blocking of a set of processes that either compete for system resources or communicate.
DEADLOCK. Contents  Principles of deadlock  Deadlock prevention  Deadlock detection.
Deadlocks CS 3100 Deadlocks1. The Deadlock Problem A set of blocked processes each holding a resource and waiting to acquire a resource held by another.
Chapter 7: Deadlocks. 7.2 Chapter Objectives To develop a description of deadlocks, which prevent sets of concurrent processes from completing their tasks.
1 Chapter 7: Deadlock. 2 The Deadlock Problem System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance.
Deadlock CSCI 444/544 Operating Systems Fall 2008.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 7: Deadlocks.
Chapter 7: Deadlocks. 7.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Bridge Crossing Example Traffic only in one direction. Each section.
Silberschatz, Galvin and Gagne  Operating System Concepts Deadlock and Starvation Deadlock – two or more processes are waiting indefinitely for.
1 School of Computing Science Simon Fraser University CMPT 300: Operating Systems I Ch 7: Deadlock Dr. Mohamed Hefeeda.
What we will cover…  The Deadlock Problem  System Model  Deadlock Characterization  Methods for Handling Deadlocks  Deadlock Prevention  Deadlock.
Deadlock Characterization
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Deadlocks.
Chapter 7 – Deadlock (Pgs 283 – 306). Overview  When a set of processes is prevented from completing because each is preventing the other from accessing.
Cosc 4740 Chapter 6, Part 4 Deadlocks. The Deadlock Problem A set of blocked processes each holding a resource and waiting to acquire a resource held.
CHAPTER 8: DEADLOCKS System Model Deadlock Characterization
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 28 Handling Deadlock.
 The Deadlock Problem  System Model  Deadlock Characterization  Methods for Handling Deadlocks  Deadlock Prevention  Deadlock Avoidance  Deadlock.
Resource Management Reusable  Disk blocks  File descriptors  Semaphores Consumable  Messages  Packets.
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education Lecture 7 Operating Systems.
1 CS.217 Operating System By Ajarn..Sutapart Sappajak,METC,MSIT Chapter 6 Deadlocks Slide 1 Chapter 6 Deadlocks.
Deadlock. Chapter 7: Deadlocks The Deadlock Problem System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock.
Chapter 7: Deadlocks. 7.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 7: Deadlocks The Deadlock Problem System Model Deadlock.
Chapter 7: Deadlocks. 7.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts - 7 th Edition, Feb 14, 2005 Chapter 7: Deadlocks The Deadlock.
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);
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.
Chapter 7: Deadlocks. The Deadlock Problem System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 7: Deadlocks.
Chapter 7: Deadlocks.
OPERATING SYSTEM CONCEPTS AND PRACTISE
Chapter 7: Deadlocks.
G.Anuradha Ref:- Galvin
Chapter 7: Deadlocks Source & Copyright: Operating System Concepts, Silberschatz, Galvin and Gagne.
Operating System: DEADLOCKS
Lecture 19: Deadlock: Conditions, Detection and Avoidance
Chapter 7 Deadlocks.
Chapter 7: Deadlocks.
Chapter 7: Deadlocks.
Deadlocks Definition A set of processes is in a Deadlock state when every process in the set is waiting for an event that can only be caused by another.
Deadlock B.Ramamurthy CSE421 1/11/2019 B.Ramamurthy.
Lecture 6: Deadlocks, Deadlock Risk Management
G.Anuradha Ref:- Galvin
Chapter 7: Deadlocks.
Outline Deadlocks, dead lock prevention, avoidance.
Deadlock Prevention Restrain the ways request can be made.
CSc 552 Advanced Unix Process deadlock deadlock prevention
DPNM Lab. Dept. of CSE, POSTECH
Deadlock B.Ramamurthy CSE421 2/23/2019 B.Ramamurthy.
Deadlocks Session - 13.
DEADLOCK.
Lecture 27 Syed Mansoor Sarwar
Lecture 19: Deadlock: Conditions, Detection and Avoidance
Deadlock B.Ramamurthy CSE421 4/23/2019 B.Ramamurthy.
Deadlock B.Ramamurthy CSE421 5/1/2019 B.Ramamurthy.
CSCI 315 Operating Systems Design
Chapter 7: Deadlocks.
Chapter 7: Deadlocks.
Chapter 8: Deadlocks Deadlock Characterization
Deadlock B.Ramamurthy CSE421 8/28/2019 B.Ramamurthy.
Deadlock B.Ramamurthy CSE421 9/3/2019 B.Ramamurthy.
Presentation transcript:

Deadlocks

fig_13_00 Example: Tasks T0 and T1 must share resources R1 and R2 They will communicate with semaphores S0 and S1 Instruction flow: T0 sets S0 = 1 and waits for R1 T0 sets S1 = 1 and waits for R2 T1 sets S1 = S1 + 1 = 2 and waits for R2 T1 sets S0 = S0 + 1 = 2 and waits for R1 No way for either task to make progress: deadlock

Example system: similar (identical copies) and dissimilar resources to be shared fig_13_00 fig_13_00

fig_13_00 Necessary conditions for deadlock: --All must hold simultaneously --These conditions are not sufficient and not independent Mutual exclusion—if process gets control of a resource no other process can use it Hold and wait—there are processes holding resources and requesting resources held by other processer No preemption—resources cannot be preempted by another process Circular wait—there is a set of processes P0, P1, …Pn where Pi is waiting for a resource held by Pi+1, i = 0,…,n-1 and Pn is waiting for a resource held by P0

fig_13_01 Deadlock analysis tool: resource allocation graph Example: suppose we have the following system of tasks and resource, where dots indicate copies of a type of resource: Waiting for resource: Holding resource: fig_13_01

fig_13_02 Example state: --if no cycles, there is no deadlock; --if there is a cycle, there is a potential for deadlock fig_13_02

fig_13_03 Example: cycle (T1,R1,T2,R5) and deadlock fig_13_03

fig_13_04 Example: cycle (T1,R1,T2,R5) but no deadlock fig_13_04

fig_13_05 Deadlock prevention: Can prevent one of necessary conditions Mutual exclusion—cannot guarantee this won’t occur, some resources are not sharable Hold and wait can require task get all resources before executing—may be inefficient Can require running task give up resources before getting a new one—may lead to starvation of low priority tasks No preemption Can allow preemption; similar problems to Hold and wait No circular wait Can put a linear order on the resources and use this to constrain task requests fig_13_05

fig_13_05 Deadlock avoidance: Algorithms need more information about how tasks use resources Example: two tasks share two resources but task scheduling guarantees that they will not both request the same resource during a given interval fig_13_05

fig_13_06 Example graph-based algorithm: using claim and request edges Claim edge: task may request resource, calculated at beginning Request edge: actual request, convert a claim edge Example: T1 has a claim on R1 but cannot request it at this time because a deadlock will occur fig_13_06

fig_13_07 Deadlock Avoidance: Banker’s algorithm Each task must state total resources it needs when it enters; “banker” uses this information to construct a schedule ensuring that an “unsafe state” will never be entered fig_13_07

fig_13_08 Example: A/D converter—10 channels fig_13_08

fig_13_09 A safe state: 2 channels are not allocated Possible schedule: T0 gets 2 free channels, completes Then T2 and finally T1 can complete fig_13_09

fig_13_10 Poor allocation: Let T1 go first; it will be blocked eventually and deadlock will occur fig_13_10

fig_13_11 Deadlock recovery: --Task termination—simple but may be too severe --Resource preemption Must take into consideration --which task to preempt --rollback considerations --starvation fig_13_11