Roadmap. Tevfik Ko!ar. CSC Operating Systems Spring Lecture - X Deadlocks - II. Louisiana State University. Deadlocks

Similar documents
Roadmap. Tevfik Koşar. CSE 421/521 - Operating Systems Fall Lecture - XI Deadlocks - II. University at Buffalo. Deadlocks. October 6 th, 2011

Roadmap. Deadlock Prevention. Deadlock Prevention (Cont.) Deadlock Detection. Exercise. Tevfik Koşar. CSE 421/521 - Operating Systems Fall 2012

CSC Operating Systems Fall Lecture - XII Deadlocks - III. Tevfik Ko!ar. Louisiana State University. October 6 th, 2009

Roadmap. Tevfik Koşar. CSE 421/521 - Operating Systems Fall Lecture - X Deadlocks - I. University at Buffalo. Synchronization structures

Roadmap. Problems with Semaphores. Semaphores. Monitors. Monitor - Example. Tevfik Koşar. CSE 421/521 - Operating Systems Fall 2012

Roadmap. Safe State. Deadlock Avoidance. Basic Facts. Safe, Unsafe, Deadlock State. Tevfik Koşar. CSC Operating Systems Spring 2007

Chapter 8: Deadlocks. The Deadlock Problem

Chapter 7: Deadlocks. Operating System Concepts 8 th Edition,

Chapter 7: Deadlocks. Chapter 7: Deadlocks. The Deadlock Problem. Chapter Objectives. System Model. Bridge Crossing Example

Chapter 7: Deadlocks

Chapter 7: Deadlocks. Operating System Concepts 9 th Edition

Chapter 7 : 7: Deadlocks Silberschatz, Galvin and Gagne 2009 Operating System Concepts 8th Edition, Chapter 7: Deadlocks

Chapter 7: Deadlocks. Operating System Concepts with Java 8 th Edition

Chapter 8: Deadlocks. Operating System Concepts with Java

Chapter 8: Deadlocks

Chapter 8: Deadlocks. The Deadlock Problem. System Model. Bridge Crossing Example. Resource-Allocation Graph. Deadlock Characterization

Deadlock Prevention. Restrain the ways request can be made. Mutual Exclusion not required for sharable resources; must hold for nonsharable resources.

Chapter 7: Deadlocks

The Deadlock Problem

Roadmap. Bounded-Buffer Problem. Classical Problems of Synchronization. Bounded Buffer 1 Semaphore Soln. Bounded Buffer 1 Semaphore Soln. Tevfik Ko!

Roadmap. Tevfik Ko!ar. CSC Operating Systems Fall Lecture - XI Deadlocks - II. Louisiana State University

Chapter 7: Deadlocks

Deadlock. Concepts to discuss. A System Model. Deadlock Characterization. Deadlock: Dining-Philosophers Example. Deadlock: Bridge Crossing Example

Module 7: Deadlocks. The Deadlock Problem

Module 7: Deadlocks. System Model. Deadlock Characterization. Methods for Handling Deadlocks. Deadlock Prevention. Deadlock Avoidance

Module 7: Deadlocks. The Deadlock Problem. Bridge Crossing Example. System Model

Chapter 7: Deadlocks. Operating System Concepts 9 th Edition

Deadlocks. Deadlock Overview

CSE Opera+ng System Principles

Chapter 7: Deadlocks. Operating System Concepts 8 th Edition,! Silberschatz, Galvin and Gagne 2009!

Deadlocks. Minsoo Ryu. Real-Time Computing and Communications Lab. Hanyang University.

CS307: Operating Systems

Chapter 7: Deadlocks

Chapter 7: Deadlocks. Operating System Concepts 9 th Edition

The Deadlock Problem. A set of blocked processes each holding a resource and waiting to acquire a resource held by another process in the set.

Chapter 7: Deadlocks. Operating System Concepts 9 th Edition! Silberschatz, Galvin and Gagne 2013!

Principles of Operating Systems

CS307 Operating Systems Deadlocks

Deadlocks. Bridge Crossing Example. The Problem of Deadlock. Deadlock Characterization. Resource-Allocation Graph. System Model

Chapter 7: Deadlocks. Operating System Concepts 8 th Edition,

Chapter 7: Deadlocks. Operating System Concepts 9 th Edition

Principles of Operating Systems

Lecture 7 Deadlocks (chapter 7)

UNIT-5 Q1. What is deadlock problem? Explain the system model of deadlock.

Potential Deadlock Example

The Slide does not contain all the information and cannot be treated as a study material for Operating System. Please refer the text book for exams.

Roadmap. Tevfik Ko!ar. CSC Operating Systems Spring Lecture - XIV Virtual Memory - I. Louisiana State University.

Chapter 7: Deadlocks. Operating System Concepts 9 th Edition

CMSC 412. Announcements

CS420: Operating Systems. Deadlocks & Deadlock Prevention

Chapter 7: Deadlocks. Operating System Concepts 9 th Edition

Deadlock Risk Management

Deadlocks. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

CHAPTER 7: DEADLOCKS. By I-Chen Lin Textbook: Operating System Concepts 9th Ed.

Deadlock. Operating Systems. Autumn CS4023

Chapter 7: Deadlocks. Operating System Concepts 9th Edition DM510-14

Operating Systems 2015 Spring by Euiseong Seo DEAD LOCK

When Deadlock Happens

The Deadlock Problem

CSC Operating Systems Spring Lecture - XIV Virtual Memory - II. Tevfik Ko!ar. Louisiana State University. March 27 th, 2008.

Chapter 7: Deadlocks. Chapter 7: Deadlocks. System Model. Chapter Objectives

Silberschatz, Galvin and Gagne 2013! CPU cycles, memory space, I/O devices! " Silberschatz, Galvin and Gagne 2013!

Chapter 8: Deadlocks. The Deadlock Problem

The Deadlock Problem. Chapter 8: Deadlocks. Bridge Crossing Example. System Model. Deadlock Characterization. Resource-Allocation Graph

COP 4610: Introduction to Operating Systems (Spring 2016) Chapter 7 Deadlocks. Zhi Wang Florida State University

Deadlocks. Prepared By: Kaushik Vaghani

Bridge Crossing Example

Chapter 8: Deadlocks. The Deadlock Problem

System Model. Types of resources Reusable Resources Consumable Resources

Deadlocks. Operating System Concepts - 7 th Edition, Feb 14, 2005

CS370 Operating Systems

Chapter 7: Deadlocks. Operating System Concepts 9 th Edition

Deadlock Prevention. Deadlock can be prevented if 1 of the 4 conditions cannot hold

The Deadlock Problem (1)

Chapter 7: Deadlocks CS370 Operating Systems

Chapter 7: Deadlocks. Chapter 7: Deadlocks. Deadlock Example. Chapter Objectives

Chapter 7: Deadlocks. Operating System Concepts 9 th Edition

Distributed Systems - II

Deadlock. A Bit More on Synchronization. The Deadlock Problem. Deadlock Characterization. Operating Systems 2/7/2005. CSC 256/456 - Spring

Roadmap. Tevfik Ko!ar. CSC Operating Systems Fall Lecture - VII CPU Scheduling - II. Louisiana State University

Roadmap. Multilevel Queue Scheduling. Multilevel Queue. Example of Multilevel Feedback Queue. Multilevel Feedback Queue. Tevfik Ko!

CS370 Operating Systems

Roadmap. Tevfik Ko!ar. CSC Operating Systems Spring Lecture - III Processes. Louisiana State University. Virtual Machines Processes

Chapter 7: Deadlocks. Operating System Concepts 8th Edition, modified by Stewart Weiss

ICS Principles of Operating Systems. Lectures Set 5- Deadlocks Prof. Nalini Venkatasubramanian

CHAPTER 7 - DEADLOCKS

Virtual Memory - I. Roadmap. Tevfik Koşar. CSE 421/521 - Operating Systems Fall Lecture - XV. University at Buffalo.

OPERATING SYSTEMS. Prescribed Text Book. Operating System Principles, Seventh Edition. Abraham Silberschatz, Peter Baer Galvin and Greg Gagne

CSC Operating Systems Spring Lecture - XII Midterm Review. Tevfik Ko!ar. Louisiana State University. March 4 th, 2008.

Deadlocks. Dr. Yingwu Zhu

CS370 Operating Systems

Virtual Memory - I. Roadmap. Background. Demand Paging. valid-invalid bit. Tevfik Koşar. CSE 421/521 - Operating Systems Fall 2012

Overview of Mass Storage Structure

Operating Systems. Designed and Presented by Dr. Ayman Elshenawy Elsefy

Deadlock and Starvation

CS370 Operating Systems

Unit-03 Deadlock and Memory Management Unit-03/Lecture-01

Outlook. Deadlock Characterization Deadlock Prevention Deadlock Avoidance

The Deadlock Problem

Deadlock Risk Management

Transcription:

CSC 4103 - Operating Systems Spring 2008 Lecture - X Deadlocks - II Tevfik Ko!ar Louisiana State University February 21 st, 2008 1 Roadmap Deadlocks Deadlock Prevention Deadlock Detection 2

Exercise (Silberschatz pp.249-251) to 3 Methods for Handling Deadlocks Ensure that the system will never enter a deadlock state.!deadlock prevention or avoidance Allow the system to enter a deadlock state and then recover.!deadlock detection Ignore the problem and pretend that deadlocks never occur in the system! Programmers should handle deadlocks (UNIX, Windows) 4

Deadlock Prevention! Ensure one of the deadlock conditions cannot hold!restrain the ways request can be made. Mutual Exclusion not required for sharable resources; must hold for nonsharable resources. Eg. read-only files Hold and Wait must guarantee that whenever a process requests a resource, it does not hold any other resources. 1. Require process to request and be allocated all its resources before it begins execution 2. or allow process to request resources only when the process has none. Example: Read from DVD to memory, then print. 1. holds printer unnecessarily for the entire execution Low resource utilization 2. may never get the printer later starvation possible 5 Deadlock Prevention (Cont.) No Preemption If a process that is holding some resources requests another resource that cannot be immediately allocated to it, then all resources currently being held are released. Preempted resources are added to the list of resources for which the process is waiting. Process will be restarted only when it can regain its old resources, as well as the new ones that it is requesting. Circular Wait impose a total ordering of all resource types, and require that each process requests resources in an increasing order of enumeration. 6

Deadlock Detection Allow system to enter deadlock state Detection algorithm Recovery scheme 7 Single Instance of Each Resource Type Maintain wait-for graph Nodes are processes. P i! P j if P i is waiting for P j. Periodically invoke an algorithm that searches for a cycle in the graph. An algorithm to detect a cycle in a graph requires an order of n 2 operations, where n is the number of vertices in the graph. 8

Resource-Allocation Graph and Wait-for Graph Resource-Allocation Graph Corresponding wait-for graph 9 Several Instances of a Resource Type Available: A vector of length m indicates the number of available resources of each type. Allocation: An n x m matrix defines the number of resources of each type currently allocated to each process. Request: An n x m matrix indicates the current request of each process. If Request [i j ] = k, then process P i is requesting k more instances of resource type. R j. 10

Detection Algorithm 1. Let Work and Finish be vectors of length m and n, respectively Initialize: (a) Work = Available (b) For i = 1,2,, n, if Allocation i " 0, then Finish[i] = false;otherwise, Finish[i] = true. 2. Find an index i such that both: (a) Finish[i] == false (b) Request i # Work If no such i exists, go to step 4. 11 Detection Algorithm (Cont.) 3. Work = Work + Allocation i Finish[i] = true go to step 2. 4. If Finish[i] == false, for some i, 1 # i # n, then the system is in deadlock state. Moreover, if Finish[i] == false, then P i is deadlocked. Algorithm requires an order of O(m x n 2) operations to detect whether the system is in deadlocked state. 12

Example of Detection Algorithm Five processes P 0 through P 4 ; three resource types A (7 instances), B (2 instances), and C (6 instances). Snapshot at time T 0 : Allocation Request Available A B C A B C A B C P 0 0 1 0 0 0 0 0 0 0 P 1 2 0 0 2 0 2 P 2 3 0 3 0 0 0 P 3 2 1 1 1 0 0 P 4 0 0 2 0 0 2 13 Example (Cont.) P 2 requests an additional instance of type C. Request A B C P 0 0 0 0 P 1 2 0 1 P 2 0 0 1 P 3 1 0 0 P 4 0 0 2 State of system? Can reclaim resources held by process P 0, but insufficient 14

Summary Deadlocks Deadlock Prevention Deadlock Avoidance Hmm.. Next Lecture: Main Memory - I Reading Assignment: Chapter 7 from Silberschatz. 15 Acknowledgements Operating Systems Concepts book and supplementary material by A. Silberschatz, P. Galvin and G. Gagne Operating Systems: Internals and Design Principles book and supplementary material by W. Stallings Modern Operating Systems book and supplementary material by A. Tanenbaum R. Doursat and M. Yuksel from UNR 16