CS 450 OPERATING SYSTEMS DEADLOCKS Manju Muralidharan Priya.

Slides:



Advertisements
Similar presentations
Chapter 7: Deadlocks.
Advertisements

Chapter 7: Deadlocks Adapted by Donghui Zhang from the original version by Silberschatz et al.
1 Concurrency: Deadlock and Starvation Chapter 6.
Deadlock and Starvation
Concurrency: Deadlock and Starvation Chapter 6. Deadlock Permanent blocking of a set of processes that either compete for system resources or communicate.
Operating Systems Lecture Notes Deadlocks Matthew Dailey Some material © Silberschatz, Galvin, and Gagne, 2002.
Chapter 6 Concurrency: Deadlock and Starvation Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community.
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.
Ceng Operating Systems Chapter 2.4 : Deadlocks Process concept  Process scheduling  Interprocess communication  Deadlocks Threads.
Operating System Concepts with Java – 7 th Edition, Nov 15, 2006 Silberschatz, Galvin and Gagne ©2007 Deadlocks  (How to Detect Them and Avoid Them) A:
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.
Concurrency: Deadlock & Starvation
CPSC 4650 Operating Systems Chapter 6 Deadlock and Starvation
1 Concurrency: Deadlock and Starvation Chapter 6.
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.
Chapter 6 Concurrency: Deadlock and Starvation
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.
7: Deadlocks1 DEADLOCKS EXAMPLES: "It takes money to make money". You can't get a job without experience; you can't get experience without a job. BACKGROUND:
Concurrency: Deadlock and Starvation Chapter 6. Goal and approach Deadlock and starvation Underlying principles Solutions? –Prevention –Detection –Avoidance.
1 Concurrency: Deadlock and Starvation Chapter 6.
Monitors High-level synchronization construct that allows the safe sharing of an abstract data type among concurrent processes. monitor monitor-name {
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Deadlocks.
Operating Systems Part III: Process Management (Deadlocks)
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.
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.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 7: Deadlocks.
CS6502 Operating Systems - Dr. J. Garrido Deadlock – Part 2 (Lecture 7a) CS5002 Operating Systems Dr. Jose M. Garrido.
Chapter 7 Deadlocks. 7.1 Introduction Deadlock Common approaches to deal with deadlock – Prevention – Avoidance – Detection and recovery.
Chapter 6 Concurrency: Deadlock and Starvation
Deadlocks System Model RAG Deadlock Characterization
Styresystemer og Multiprogrammering Block 3, 2005 Deadlocks Robert Glück.
1 OPERATING SYSTEMS DEADLOCKS created by:-gaurav shrivastava contact:- om.
Chapter 6 Concurrency: Deadlock and Starvation Operating Systems: Internals and Design Principles, 6/E William Stallings.
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education Lecture 7 Operating Systems.
Operating Systems Unit VI Deadlocks and Protection Department of Computer Science Engineering and Information Technology.
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.
Deadlocks Introduction to Operating Systems: Module 7.
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.
Informationsteknologi Monday, October 1, 2007Computer Systems/Operating Systems - Class 111 Today’s class 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);
Chapter 7: Deadlocks.
ITEC 202 Operating Systems
G.Anuradha Ref:- Galvin
Deadlock Permanent blocking of a set of process that compete for system resources or communicate with each other. Conditions that characterizes deadlock.
Chapter 6 : Deadlocks What is a Deadlock?
Operating System: DEADLOCKS
OPERATING SYSTEMS DEADLOCKS
Process Deadlocks.
Chapter 7: Deadlocks.
G.Anuradha Ref:- Galvin
Deadlocks Session - 13.
DEADLOCK.
Lecture 27 Syed Mansoor Sarwar
OPERATING SYSTEMS DEADLOCKS.
OPERATING SYSTEMS DEADLOCKS.
DEADLOCKS.
Chapter 8: Deadlocks Deadlock Characterization
Presentation transcript:

CS 450 OPERATING SYSTEMS DEADLOCKS Manju Muralidharan Priya

Objective At the end of this presentation, you will know: What is a Deadlock? Preventing and Avoiding Deadlocks Detecting Deadlocks Recovery Schemes 2 CS 561 Deadlocks

What is a Deadlock? “ To get a job, you need experience. To gain experience you need a job ” Definition: The permanent blocking of a set of processes that compete for the system resources or communicate with each other. CS 561 Deadlocks 3

The Dining Philosopher’s Problem 5 Philosophers 5 Forks All Philosophers need a left fork and a right fork to eat. Deadlock : All philosophers reach for the left fork at the same time. CS 561 Deadlocks 4

System Model System has processes and resources Processes can – Request & wait for a resource – Use the resource – Release the resource after use. Deadlock: Each process is waiting for a resource being held by the other process. CS 561 Deadlocks 5 R1 R2 P1 P2 Hold Request

Deadlock Characterization Conditions for a deadlock to occur Mutual Exclusion : A resource can be used only by one process at a time. Hold & Wait : A process can retain holds on resources while it waits for other. No Preemption : No resource can be forcibly removed from a process holding it. Circular Wait : Process 1 is waiting for Process 2, Process 2 is waiting for Process 3 and Process 3 is waiting for process 1 All 4 of the above must happen at the same time for deadlock to occur. CS 561 Deadlocks 6

Resource Allocation graphs Depicts the state of the system of resources and processes Process Resource and instances Request from process to resource Allocated instance CS 561 Deadlocks 7 PiPi RiRi PiPi RiRi PiPi RiRi

Resource Allocation Graph with cycle and deadlock Resource Allocation Graph with cycle and no deadlock CS 561 Deadlocks 8 P1P1 P2P2 P3P3 P3P3 P3P3 P2P2 P1P1 R1R1 R2R2 R4R4 R3R3 R2R2 R1R1

Handling Deadlocks Ostrich Algorithm – Pretend there is no problem Deadlock Prevention – Stop the four conditions from happening Deadlock Avoidance – Allow deadlock conditions – Calculate safe and unsafe states Deadlock Detection – Allow the deadlock to happen – Recover from the deadlock CS 561 Deadlocks 9 Stop Deadlock from happening

Deadlock Prevention Mutual Exclusion – Disallow mutual exclusion for sharable resources Hold & Wait – Process requests all requires resources at one time. – Low resource utilization & Starvation No Preemption – Process must let go of all holds before making a new request Circular Wait – Define linear ordering on resources CS 561 Deadlocks 10

State of the system is calculated – Unsafe State : Deadlock may occur. – Safe State : Ample resource instances exist. – Denial of resource allocation happens if request causes unsafe state CS 561 Deadlocks 11 SAFE DEADLOCK UNSAFE O.S. can avoid deadlock. Only with luck will processes avoid deadlock. Deadlock Avoidance

Deadlock Avoidance contd. Assume a simple model: – 3 Processes & 12 Magnetic tape drives. – The current state is as follows: CS 561 Deadlocks 12 The safe order of execution is The system enters an unsafe state when p2 requests and is allocated another tape. A safety algorithm is used to detect the safe state by calculating the needs of the processes and the amount of resource allocated.

When resource has only one instance: – Use resource allocation graph to detect cycles When resource has multiple instances: – Cycles do not mean deadlocks – Use Banker’s algorithm All processes must return resources within a finite amount of time. Processes may have to wait for allocation CS 561 Deadlocks 13 Deadlock Avoidance contd.

Deadlock Detection Let the deadlock happen Detect deadlock – For single instance resource : Detect cycle with Resource Allocation Graph – For multiple instance resource keep track of: Available resources Allocated resources Number of requests made Recover from deadlock CS 561 Deadlocks 14

Recovery Techniques Abort all deadlocked processes. Rollback deadlocked process to previous checkpoint and restart. Abort deadlocked process successively till deadlock disappears. Preempt deadlocked resources till deadlock disappears CS 561 Deadlocks 15

Criterion for aborting and preempting processes Least consumption of processor time Least amount of output produced Most time remaining Least total allocated resources Lowest priority CS 561 Deadlocks 16 Recovery Techniques contd.

Wrapping up… There are strengths and weaknesses to all approaches Use a different strategy in different situations depending on: – Memory – Internal resources – Process resources CS 561 Deadlocks 17

THANK YOU CS 561 Deadlocks 18