Deadlock. Rab Nawaz Jadoon DCS. Assistant Professor COMSATS Lahore Pakistan. Department of Computer Science

Similar documents
Chapter seven: Deadlock and Postponement

6. Concurrency: Deadlock

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

CSE 306/506 Operating Systems Deadlock. YoungMin Kwon

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.

Process Management. Deadlock. Process Synchronization. Management Management. Starvation

UNIT 4 DEADLOCKS 4.0 INTRODUCTION

Concurrency: Deadlock and Starvation. Chapter 6

CS420: Operating Systems. Deadlocks & Deadlock Prevention

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

Operating Systems ECE344. Ding Yuan

Chapter - 4. Deadlocks Important Questions

The Deadlock Problem (1)

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

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

ECE519 Advanced Operating Systems

Principles of Operating Systems

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

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

COMPUTER SCIENCE 4500 OPERATING SYSTEMS

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

Computer Science 4500 Operating Systems

Principles of Operating Systems

Lecture 10 Multithreading

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

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

Bridge Crossing Example

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

Chapter 7: Deadlocks

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

Chapter 6. Deadlocks

Chapter 7: Deadlocks. Operating System Concepts 9 th Edition

Chapter 8: Deadlocks. The Deadlock Problem

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

Deadlocks. Copyright : University of Illinois CS 241 Staff 1

OPERATING SYSTEMS. Deadlocks

Deadlock 1 Chapter 6

The Deadlock Problem

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

Chapter 3. Deadlocks

Last Class: Monitors. Real-world Examples

Chapter 3. Deadlocks

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

Chapter 8: Deadlocks

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

CS307 Operating Systems Deadlocks

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

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

Deadlock 1 Chapter 6

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

Chapter 7: Deadlocks

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

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

Resources. Chapter 3. Deadlocks. Resources. Resources

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.

Deadlock and Starvation

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

Chapter 7: Deadlocks

CMSC 412. Announcements

Deadlocks. Prepared By: Kaushik Vaghani

Deadlocks. Deadlock Overview

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

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

Introduction to Deadlocks

System Model. Types of resources Reusable Resources Consumable Resources

The Deadlock Problem

COMP 346 WINTER Tutorial 9 DEADLOCK

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

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

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

Chapter 3: Deadlocks

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

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

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

Module 7: Deadlocks. The Deadlock Problem

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

Chapter 8: Deadlocks. The Deadlock Problem

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

Deadlock. Concurrency: Deadlock and Starvation. Reusable Resources

Chapter 7: Deadlocks

CS307: Operating Systems

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

Lecture 7 Deadlocks (chapter 7)

Deadlocks. Dr. Yingwu Zhu

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

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

Deadlocks. System Model

Readings and References. Deadlock. Deadlock. Simple Traffic Gridlock Example. Reading. CSE Computer Systems November 30, 2001.

More on Synchronization and Deadlock

Potential Deadlock Example

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

CSE Opera+ng System Principles

Deadlock Risk Management

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

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

Chapter 7: Deadlocks. Operating System Concepts 9 th Edition

What is the Race Condition? And what is its solution? What is a critical section? And what is the critical section problem?

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

Deadlock Revisited. CS439: Principles of Computer Systems November 29, 2017

Transcription:

Deadlock Rab Nawaz Jadoon DCS COMSATS Institute of Information Technology Assistant Professor COMSATS Lahore Pakistan Operating System Concepts

Deadlock A process in a multiprogramming system is said to be in deadlock if it is waiting for an event that will never occur. In a System deadlock one or more processes are deadlocked. In multiprogramming system resource sharing is one of the primary goal of the OS. 2

Examples of deadlocks A traffic deadlock 3

Real traffic deadlock 4

Simple resource deadlock Most deadlocks develop because of the normal contention for dedicated resources Deadlock Circular wait is characteristic of deadlocked systems 5

Necessary conditions for Deadlock Four necessary conditions for deadlocks, Mutual exclusion condition Resource may be acquired exclusively by only one process at a time Wait-for condition (hold-and-wait condition) Process that has acquired an exclusive resource may hold that resource while the process waits to obtain other resources No-preemption condition Once a process has obtained a resource, the system cannot remove it from the process s control until the process has finished using the resource Circular-wait condition Two or more processes are locked in a circular chain in which each process is waiting for one or more resources that the next process in the chain is holding 6

Deadlock solutions There are four solution proposed by the different researcher, Deadlock prevention Deadlock avoidance Deadlock detection Deadlock recovery 7

Deadlock prevention Deadlock Prevention Havender suggested that if any of the four necessary conditions is denied, a deadlock cannot occur. Condition a system to remove any possibility of deadlocks occurring

Denying the Wait-For Condition When denying the wait-for condition All of the resources a process needs to complete its task must be requested at once. The system should grant on all or none basis. If available Grant Else wait till all requested are available. This leads to inefficient resource allocation. This can cause indefinite postponement, since not all the required resources may become available at once.

Denying the No-Preemption Condition When denying the no-preemption condition Processes may lose work when resources are preempted. According to 2 nd strategy, Havender suggested that when a process holding resources is denied a request for additional resources, that process must release its held resources, and if necessary request them again together with the additional resources. This can lead to substantial overhead as processes must be restarted, Repeatedly requests and releases the same resources.

Denying the Circular-Wait Condition Denying the circular-wait condition: Uses a linear ordering of resources to prevent deadlock More efficient resource utilization than the other strategies Drawbacks Not as flexible or dynamic as desired Requires the programmer to determine the ordering or resources for each system

Denying the Circular-Wait Condition Havender s linear ordering of resources for preventing deadlock.

Dijkstra s Banker s Algorithm Deadlock Avoidance Impose less stringent conditions than in deadlock prevention in an attempt to get better resource utilization. Safe state Operating system can guarantee that all current processes can complete their work within a finite time Unsafe state Does not imply that the system is deadlocked, but that the OS cannot guarantee that all current processes can complete their work within a finite time

Banker s Algorithm (cont.) Cont. Requires that resources be allocated to processes only when the allocations result in safe states. It has a number of weaknesses (such as requiring a fixed number of processes and resources) that prevent it from being implemented in real systems

Example of a safe State Safe state.

Example of an Unsafe State Unsafe state.

Banker s Algorithm Resource Allocation State description of three processes. Is the above state safe?

Weaknesses in the Banker s Algorithm Weaknesses Requires there be a fixed number of resource to allocate Requires the population of processes to be fixed Requires the banker to grant all requests within finite time Requires that clients repay all loans within finite time Requires processes to state maximum needs in advance

Deadlock detection Deadlock Detection Used in systems in which deadlocks can occur Determines if deadlock has occurred Identifies those processes and resources involved in the deadlock Deadlock detection algorithms can incur significant runtime overhead

Resource-allocation graphs Squares Represent processes Large circles Resource-Allocation Graphs Represent classes of identical resources Small circles drawn inside large circles Indicate separate identical resources of each class

Resource-Allocation Graphs Resource-allocation and request graphs.

Reduction of Resource-Allocation Graphs Graph reductions If a process s resource requests may be granted, the graph may be reduced by that process If a graph can be reduced by all its processes, there is no deadlock If a graph cannot be reduced by all its processes, the irreducible processes constitute the set of deadlocked processes in the graph

Reduction of Resource-Allocation Graphs Graph reductions determining that no deadlock exists.

Deadlock recovery Deadlock Recovery Clears deadlocks from system so that deadlocked processes may complete their execution and free their resources Suspend/resume mechanism Allows system to put a temporary hold on a process Suspended processes can be resumed without loss of work Checkpoint/Rollback Facilitates suspend/resume capabilities Limits the loss of work to the time the last checkpoint was made

Deadlock Strategies in Current and Future Systems Deadlock is viewed as limited annoyance in personal computer systems Some systems implement basic prevention methods suggested by Havender Some others ignore the problem, because checking deadlocks would reduce systems performance Deadlock continues to be an important research area.

26