Deadlock Prevention & Avoidance Department of Computer Science Southern Illinois University Edwardsville Spring, 2016 Dr. Hiroshi Fujinoki

Slides:



Advertisements
Similar presentations
1 Concurrency: Deadlock and Starvation Chapter 6.
Advertisements

Deadlock Prevention, Avoidance, and Detection
Concurrency: Deadlock and Starvation Chapter 6. Deadlock Permanent blocking of a set of processes that either compete for system resources or communicate.
Deadlock Prevention, Avoidance, and Detection.  The Deadlock problem The Deadlock problem  Conditions for deadlocks Conditions for deadlocks  Graph-theoretic.
Lecture 7: Deadlock     Necessary Conditions for Deadlock     Deadlock Prevention - Havender's Linear Ordering Deadlock Avoidance Deadlock Detection &
Ceng Operating Systems Chapter 2.4 : Deadlocks Process concept  Process scheduling  Interprocess communication  Deadlocks Threads.
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
Chapter 7 Deadlocks. 7.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts - 7 th Edition, Feb 14, 2005 Chapter 7: Deadlocks 7.1 System Model.
DPNM Lab. Dept. of CSE, POSTECH
CSC 322 Operating Systems Concepts Lecture - 29: by
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.
The ‘deadlock’ conditions Reviewing some key points concerning the potential for ‘deadlock’ in an operating system.
CH 3 Deadlock When 2 (or more) processes remain blocked forever!
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-6 Deadlocks Department of Computer Science and Software Engineering.
Deadlocks Silberschatz Ch. 7 and Priority Inversion Problems.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 28 Handling Deadlock.
Operating Systems (CS 340 D) Princess Nora University Faculty of Computer & Information Systems Computer science Department.
CS6502 Operating Systems - Dr. J. Garrido Deadlock – Part 2 (Lecture 7a) CS5002 Operating Systems Dr. Jose M. Garrido.
Operating Systems (CS 340 D) Dr. Abeer Mahmoud Princess Nora University Faculty of Computer & Information Systems Computer science Department.
Operating System Concepts and Techniques Lecture 15 Deadlock and starvation-1 M. Naghibzadeh Reference M. Naghibzadeh, Operating System Concepts and Techniques,
Chapter 7: Deadlocks. 7.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts - 7 th Edition, Feb 14, 2005 Chapter 7: Deadlocks The Deadlock.
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.
CS307 Operating Systems Deadlocks Fan Wu Department of Computer Science and Engineering Shanghai Jiao Tong University Spring 2012.
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.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 6: Deadlocks.
Deadlocks 12/02/2015. What is a deadlock ? System has a finite set of resources. Resource can have one or more instances. Processes compete for resources.
Silberschatz, Galvin and Gagne ©2009 Edited by Khoury, 2015 Operating System Concepts – 9 th Edition, Chapter 7: Deadlocks.
Deadlock A deadlock is a situation wherein two or more competing actions are waiting for the other to finish, and thus neither ever does. Example : “When.
CH 3 Deadlock When 2 (or more) processes remain blocked forever!
Informationsteknologi Monday, October 1, 2007Computer Systems/Operating Systems - Class 111 Today’s class Deadlock.
Chapter 7: Deadlocks. 7.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 7: Deadlocks The Deadlock Problem System Model Deadlock.
Deadlocks CPE Operating Systems
Chapter 7 Deadlocks 1. Objectives and Outline Outline The Deadlock Problem System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock.
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 Operating Systems (CC2011NI) -Mr. Pranoy Man Pradhan.
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.
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.
Process Management Deadlocks.
Operating Systems, Summer Semester 2011
Operating Systems, Winter Semester 2011
ITEC 202 Operating Systems
Chapter 6 : Deadlocks What is a Deadlock?
Operating Systems (CS 340 D)
Operating System: DEADLOCKS
Lecture 19: Deadlock: Conditions, Detection and Avoidance
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.
Deadlocks Peng Lu In a multiprogramming environment, several processes may compete for a finite number of resources. A process requests resources; if the.
Chapter 3 Deadlocks 3.1. Resource 3.2. Introduction to deadlocks
Deadlocks Session - 13.
DEADLOCK.
Lecture 27 Syed Mansoor Sarwar
Lecture 19: Deadlock: Conditions, Detection and Avoidance
Chapter 3 Deadlocks 3.1. Resource 3.2. Introduction to deadlocks
OPERATING SYSTEMS DEADLOCKS.
Deadlock Prevention & Avoidance
IT3002 Computer Architecture
Deadlock A deadlock situation on a resource can arise if and only if all of the following conditions hold simultaneously in a system: Mutual exclusion.
OPERATING SYSTEMS DEADLOCKS.
DEADLOCKS.
Introduction to Deadlocks
Chapter 3 Deadlocks 3.1. Resource 3.2. Introduction to deadlocks
Deadlock Prevention & Avoidance
Uniprocessor Process Management & Process Scheduling
Presentation transcript:

Deadlock Prevention & Avoidance Department of Computer Science Southern Illinois University Edwardsville Spring, 2016 Dr. Hiroshi Fujinoki CS 314 Operating Systems Deadlock_Detection/000

CS 314 Operating Systems Deadlock_Avoidance/001 Deadlock Prevention Try to prevent any one of the four necessary conditions for a deadlock  Mutual Exclusion  Hold & Wait  Circular wait  Non preemptive resources

CS 314 Operating Systems Deadlock_Avoidance/002 Attacking mutual exclusion Some resources inherently require mutual exclusion Mutual Exclusion = While a process is using a resource no other process can use the same resource Example Problem Printers Files for updates CD-Rs

CS 314 Operating Systems Deadlock_Avoidance/003 Attacking hold & wait  Require all processes to acquire all the needed resources at once (a) Resource request does not have to be at the beginning of a process (b) If any of the required resource is not available, drop everything (then try it again later) (c) Any process can not make a request for any new resource, while the process currently has any resource  A process does NOT have to request all the resources at once (a) Whenever an additional resource is needed, drop all what are possessed by this process and request everything at once (b) If any process steals your resource(s) when you temporarily have to wait until all resources become available

CS 314 Operating Systems Deadlock_Avoidance/004 Attacking hold & wait Possible “Hold & Wait” 1-(b) “Hold & Wait” 1-(a) 1-(c) Time # of resources acquired Time

CS 314 Operating Systems Deadlock_Avoidance/005 Attacking hold & wait Time # of resources acquired 2-(a) Another Process If any of resources is missing, drop everything Drop all what you possess first Then you try to get all you need # of resources acquired Time 2-(b)

CS 314 Operating Systems Deadlock_Avoidance/006 Attacking non-preemption The same problem we had for “mutual exclusion” “Attacking Non-Preemption” Problem = Allow preemption = You process can loose your resource at any time No one will be happy in loosing a CD-R drive in the middle of burning a CD

CS 314 Operating Systems Deadlock_Avoidance/007 Circular-Wait Assign unique ID for every non-sharable resource in a system Every process must start requesting resources in either ascending or descending order of resource IDs A B X1X1 Y2Y2 Z3Z3 Request (X, Y, Z) (Y, Z)

CS 314 Operating Systems Deadlock_Avoidance/008 Circular-Wait Assign unique ID for every non-sharable resource in a system Every process must start requesting resources in either ascending or descending order of resource IDs A B X1X1 Y2Y2 Z3Z3 Assigned Request (X, Y, Z) (Y, Z)

CS 314 Operating Systems Deadlock_Avoidance/009 Circular-Wait Assign unique ID for every non-sharable resource in a system Every process must start requesting resources in either ascending or descending order of resource IDs A B X1X1 Y2Y2 Z3Z3 Assigned Request (X, Y, Z) (Y, Z)

CS 314 Operating Systems Deadlock_Avoidance/010 Circular-Wait Assign unique ID for every non-sharable resource in a system Every process must start requesting resources in either ascending or descending order of resource IDs A B X1X1 Y2Y2 Z3Z3 Assigned (X, Y, Z) (Y, Z) Assigned Requested Deadlock

CS 314 Operating Systems Deadlock_Avoidance/011 Circular-Wait Assign unique ID for every non-sharable resource in a system Every process must start requesting resources in either ascending or descending order of resource IDs A B X1X1 Y2Y2 Z3Z3 Assigned (X, Y, Z) (Y, Z) Request Process B blocks Request

CS 314 Operating Systems Deadlock_Avoidance/012 Circular-Wait Assign unique ID for every non-sharable resource in a system Every process must start requesting resources in either ascending or descending order of resource IDs A B X1X1 Y2Y2 Z3Z3 Assigned (X, Y, Z) (Y, Z) Request Process B blocks Assigned Process A Completes

CS 314 Operating Systems Deadlock_Avoidance/013 Circular-Wait Assign unique ID for every non-sharable resource in a system Every process must start requesting resources in either ascending or descending order of resource IDs B X1X1 Y2Y2 Z3Z3 (Y, Z) Request

CS 314 Operating Systems Deadlock_Avoidance/014 Circular-Wait Assign unique ID for every non-sharable resource in a system Every process must start requesting resources in either ascending or descending order of resource IDs B X1X1 Y2Y2 Z3Z3 (Y, Z) Assigned Requested

CS 314 Operating Systems Deadlock_Avoidance/015 Circular-Wait Assign unique ID for every non-sharable resource in a system Every process must start requesting resources in either ascending or descending order of resource IDs B X1X1 Y2Y2 Z3Z3 (Y, Z) Assigned Process B completes

CS 314 Operating Systems Deadlock_Avoidance/016 Deadlock Avoidance When a process makes a request to a resource, the OS simulates if it will cause a deadlock in the future if no one releases their currently-held resource: If it will cause a deadlock If it will not cause a deadlock the request is denied (“unsafe state”) the requested resource is granted (“safe state”)

CS 314 Operating Systems Deadlock_Avoidance/016 The two states defined in Deadlock Avoidance A system is in “safe state” if there is at least one assignment schedule to complete all the processes without deadlock and without any process releasing their resources  Safe State  Unsafe State If a system is not in safe state, the system must be in “unsafe state” If a system is in safe state, deadlock can always be avoided If a system is in unsafe state, deadlock may not be avoided (deadlock will never happen even in the worst case) (deadlock can happen in the worst case)

CS 314 Operating Systems Deadlock_Avoidance/017 ProcessAssigned MAX. NeedRequests Pending Process Status ProcessAssigned MAX. Need B A C B A C The number of requests a process made, but not granted because OS does not have the requested resources Requests Pending Process Status If a process has at least one pending request, process is BLOCKED Otherwise a process is RUNNING If a process gets all required resources then, the process becomes COMPLTED RUNNING

CS 314 Operating Systems ProcessAssigned MAX. NeedRequests Pending Process Status B A C RUNNING Available 4 Assume: 11 instances of the resource R exist Deadlock_Avoidance/018

CS 314 Operating Systems ProcessAssigned MAX. NeedRequests Pending Process Status B A C RUNNING Available 4 Assume: 11 instances of the resource R exist If Process A requests 4 more instances of this resource ProcessAssigned MAX. NeedRequests Pending Process Status B A C RUNNING Available This is “unsafe state” But Not Deadlock yet Deadlock_Avoidance/018

CS 314 Operating Systems ProcessAssigned MAX. NeedRequests Pending Process Status B A C RUNNING Available 4 Assume: 11 instances of the resource R exist If Process A requests 1 more instances of this resource ProcessAssigned MAX. NeedRequests Pending Process Status B A C RUNNING Available BLOCKED Deadlock_Avoidance/019

CS 314 Operating Systems ProcessAssigned MAX. NeedRequests Pending Process Status B A C RUNNING Available 4 Assume: 11 instances of the resource R exist If Process B requests 2 more instances of this resource ProcessAssigned MAX. NeedRequests Pending Process Status B A C RUNNING Available 0 7BLOCKED 2 Deadlock_Avoidance/020

CS 314 Operating Systems ProcessAssigned MAX. NeedRequests Pending Process Status B A C RUNNING Available 4 Assume: 11 instances of the resource R exist If Process C requests 2 more instances of this resource ProcessAssigned MAX. NeedRequests Pending Process Status B A C RUNNING Available 0 7BLOCKED Now Deadlock 2 BLOCKED 2 Deadlock_Avoidance/021

CS 314 Operating Systems ProcessAssigned MAX. NeedRequests Pending Process Status B A C RUNNING Available 4 Assume: 11 instances of the resource R exist If Process B requests 2 more instances of this resource ProcessAssigned MAX. NeedRequests Pending Process Status B A C RUNNING Available This is “safe state” 0 Deadlock_Avoidance/022

CS 314 Operating Systems ProcessAssigned MAX. NeedRequests Pending Process Status B A C RUNNING Available 4 Assume: 11 instances of the resource R exist If Process B requests 2 more instances of this resource ProcessAssigned MAX. NeedRequests Pending Process Status B A C RUNNING Available 6 0 This is “safe state” COMPLETED Deadlock_Avoidance/023