Chapter 3. Deadlocks

Similar documents
Resources. Lecture 4. Deadlocks. Resources (2) Resources (1) Four Conditions for Deadlock. Introduction to Deadlocks

Chapter 3. Deadlocks

DEADLOCKS M O D E R N O P E R A T I N G S Y S T E M S C H A P T E R 6 S P R I N G

Deadlocks Prof. James L. Frankel Harvard University. Version of 7:05 PM 7-Mar-2017 Copyright 2017, 2015 James L. Frankel. All rights reserved.

Chapter 6. Deadlocks

Resources. Chapter 3. Deadlocks. Resources. Resources

Deadlocks. Thomas Plagemann. With slides from C. Griwodz, K. Li, A. Tanenbaum and M. van Steen

Chapter 3: Deadlocks

Learning Outcomes. Chapter 3. Deadlocks. Resources. Resources. Resources

Operating Systems. Lecture3.2 - Deadlock Management. Golestan University. Hossein Momeni

Learning Outcomes. Chapter 6. Deadlocks. Resources. Resources & Deadlocks. Resource Access. Two example resource usage patterns

CS450/550 Operating Systems

Deadlocks. Today. Next Time. ! Resources & deadlocks! Dealing with deadlocks! Other issues. ! Memory management

Deadlocks. Today. Next Time. Resources & deadlocks Dealing with deadlocks Other issues. I/O and file systems

Deadlocks. Tore Larsen. With slides from T. Plagemann, C. Griwodz, K. Li, A. Tanenbaum and M. van Steen

Introduction to OS. Deadlock. MOS Ch. 6. Mahmoud El-Gayyar. Mahmoud El-Gayyar / Introduction to OS 1

Deadlocks. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Chapter 3: Deadlocks. Chapter 3

MODERN OPERATING SYSTEMS. Third Edition ANDREW S. TANENBAUM. Chapter 6 Deadlocks

Concurrency problems. To do. q Non-deadlock bugs q Resources & deadlocks q Dealing with deadlocks q Other issues q Next Time: I/O and file systems

Operating Systems. Deadlock. User OS. Kernel & Device Drivers. Interface Programs. Brian Mitchell - Operating Systems

Concurrency problems. q Non-deadlock bugs q Resources & deadlocks q Dealing with deadlocks q Other issues q Next Time: I/O and file systems

MODERN OPERATING SYSTEMS. Third Edition ANDREW S. TANENBAUM. Chapter 6 Deadlocks

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

CISC 7310X. C10: Deadlocks. Hui Chen Department of Computer & Information Science CUNY Brooklyn College. 4/12/2018 CUNY Brooklyn College

Shared and Preemptable Resources. A few resources may be sharable. Anyone can write the system log.

More on Synchronization and Deadlock

11 Resource Management Deadlock and Starvation

Process P holds resource R. Process P is waiting for resource R. P Process P holds T and requests R. R Process Q holds R and requests T

COMPUTER SCIENCE 4500 OPERATING SYSTEMS

Computer Science 4500 Operating Systems. In This Module. Deadlock Definition. Module 7 Deadlocks

Computer Science 4500 Operating Systems

Deadlocks. Operating Systems. Resources. Deadlocks

OPERATING SYSTEMS. After A.S.Tanenbaum, Modern Operating Systems, 3rd edition. Uses content with permission from Assoc. Prof. Florin Fortis, PhD

Deadlock and Starvation

Chapter 6. Deadlock. (A Quick Introduction)

! What is a deadlock? ! What causes a deadlock? ! How do you deal with (potential) deadlocks? Maria Hybinette, UGA

Chapter 6 - Deadlocks

Deadlock 1 Chapter 6

Deadlock 1 Chapter 6

!! What is a deadlock? !! What causes a deadlock? !! How do you deal with (potential) deadlocks? Maria Hybinette, UGA

Chap. 3. Input/Output

CSE 380 Computer Operating Systems

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.

COS 318: Operating Systems. Deadlocks. Jaswinder Pal Singh Computer Science Department Princeton University

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

System Model. Deadlocks. Deadlocks. For example: Semaphores. Four Conditions for Deadlock. Resource Allocation Graph

Deadlock and Starvation

Operating Systems ECE344. Ding Yuan

ECS 150 (Operating Systems) Goal To examine what causes deadlock, and what to do about it. Spring Quarter

Fig Bridge crossing - deadlock

UNIT 4 DEADLOCKS 4.0 INTRODUCTION

CSE 306/506 Operating Systems Deadlock. YoungMin Kwon

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

6. Concurrency: Deadlock

Chapter 7: Deadlocks 1

Comp 204: Computer Systems and Their Implementation. Lecture 9: Deadlock

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.

Chapter 8: Deadlocks. The Deadlock Problem

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

Deadlocks. System Model

Deadlocks. Mehdi Kargahi School of ECE University of Tehran Spring 2008

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

Bridge Crossing Example

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

Chapter 7: Deadlocks

Operating Systems. Deadlocks

CSE120 Principles of Operating Systems. Prof Yuanyuan (YY) Zhou Deadlock

Outline. Deadlock. Examples, Conditions, Strategies. Deadlock Prevention. Deadlock Avoidance. Banker s algorithm

Chapter - 4. Deadlocks Important Questions

Final Exam Review. CPSC 457, Spring 2016 June 29-30, M. Reza Zakerinasab Department of Computer Science, University of Calgary

System Model. Types of resources Reusable Resources Consumable Resources

The Deadlock Problem

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

Administrivia. Assignments 0 & 1 Class contact for the next two weeks Next week. Following week

OPERATING SYSTEMS. Deadlocks

Operating Systems CMPSC 473. Deadlocks February 28, Lecture 13 Instructor: Trent Jaeger

Deadlocks. Dr. Yingwu Zhu

Chapter 8: Deadlocks

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

Chapter 7: Deadlocks

VI. Deadlocks. What is a Deadlock? Intended Schedule. Deadlock Problem (1) ???

VI. Deadlocks Operating Systems Prof. Dr. Marc H. Scholl DBIS U KN Summer Term

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

Chapter 7: Deadlocks

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

Chapter 8: Deadlocks. Bridge Crossing Example. The Deadlock Problem

Chapter 7: Deadlocks. Operating System Concepts 9 th Edition

CS Operating Systems

CS Operating Systems

What is Deadlock? Two or more entities need a resource to make progress, but will never get that resource. Examples from everyday life:

CSCC 69H3 2/1/13. Today: Deadlock. Remember example from last week? Example of Deadlock. Example: dining philosophers: Not just an OS Problem!

Deadlocks. Prepared By: Kaushik Vaghani

CSC 539: Operating Systems Structure and Design. Spring 2005

The Deadlock Problem

CSE Opera+ng System Principles

Concurrency: Deadlock and Starvation. Chapter 6

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

Operating systems. Lecture 5. Deadlock: System Model. Deadlock: System Model. Process synchronization Deadlocks. Deadlock: System Model

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

Transcription:

Chapter 3 Deadlocks 3.1. Resource 3.2. Introduction to deadlocks 3.3. The ostrich algorithm 3.4. Deadlock detection and recovery 3.5. Deadlock avoidance 3.6. Deadlock prevention 3.7. Other issues

Resources Examples of computer resources printers tape drives tables Processes need access to resources in reasonable order Suppose a process holds resource A and requests resource B at same time another process holds B and requests A both are blocked and remain so forever

Resources (1) Deadlocks occur when processes are granted exclusive access to devices, files, and so forth we refer to these objects generally as resources Preemptable resources can be taken away from a process with no ill effects Nonpreemptable resources will cause the process to fail if taken away

Resources (2) Sequence of events required to use a resource 1.request the resource 2.use the resource 3.release the resource Must wait if request is denied requesting process may be blocked may fail with error code

Resource Acquisition Using a semaphore to protect resources.

Resource Acquisition Which has a potential deadlock?

Introduction to Deadlocks Formal definition : A set of processes is deadlocked if each process in the set is waiting for an event that only another process in the set can cause Usually the event is release of a currently held resource None of the processes can run release resources be awakened

Four Conditions for Deadlock 1. Mutual exclusion condition each resource assigned to 1 process or is available 2. Hold and wait condition process holding resources can request additional 3. No preemption condition previously granted resources cannot forcibly taken away 4. Circular wait condition must be a circular chain of 2 or more processes each is waiting for resource held by next member of the chain

Deadlock Modeling (2) 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

Deadlock Modeling (3) A B C How deadlock occurs

Deadlock Modeling (4) (o) (p) (q) How deadlock can be avoided

Deadlock Modeling (5) Strategies for dealing with Deadlocks 1. just ignore the problem altogether 2. detection and recovery 3. dynamic avoidance careful resource allocation 4. prevention negating one of the four necessary conditions

The Ostrich Algorithm Pretend there is no problem Reasonable if deadlocks occur very rarely cost of prevention is high UNIX and Windows takes this approach It is a trade off between convenience correctness

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

Detection with One Resource of Each Type (2) Data structures needed by deadlock detection algorithm

Detection with One Resource of Each Type (3) 2 2 An example for the deadlock detection algorithm

Detection with One Resource of Each Type (3) 1 An example for the deadlock detection algorithm

Recovery from Deadlock (1) Recovery through preemption take a resource from some other process depends on nature of the resource Recovery through rollback checkpoint a process periodically use this saved state restart the process if it is found deadlocked

Recovery from Deadlock (2) Recovery through killing processes crudest but simplest way to break a deadlock kill one of the processes in the deadlock cycle the other processes get its resources choose process that can be rerun from the beginning

Deadlock Avoidance Resource Trajectories Two process resource trajectories

Safe and Unsafe States (1) (a) (b) (c) (d) (e) Demonstration that the state in (a) is safe

Safe and Unsafe States (2) (a) (b) (c) (d) Demonstration that the sate in b is not safe

The Banker's Algorithm for a Single Resource (a) (b) (c) Three resource allocation states safe safe unsafe

Banker's Algorithm for Multiple Resources Example of banker's algorithm with multiple resources

Deadlock Prevention Attacking the Mutual Exclusion Condition Some devices (such as printer) can be spooled only the printer daemon uses printer resource thus deadlock for printer eliminated Not all devices can be spooled Principle: avoid assigning resource when not absolutely necessary as few processes as possible actually claim the resource

Attacking the Hold and Wait Condition Require processes to request resources before starting a process never has to wait for what it needs Problems may not know required resources at start of run also ties up resources other processes could be using Variation: process must give up all resources then request all immediately needed

Attacking the No Preemption Condition This is not a viable option Consider a process given the printer halfway through its job now forcibly take away printer!!??

Attacking the Circular Wait Condition (1) (a) (b) Numerically ordered resources A resource graph

Summary of approaches to deadlock prevention