Chapter 6 Concurrency: Deadlock and Starvation II zDeadlock zConditions for Deadlock zDeadlock Prevention zDeadlock Avoidance zBanker’s Algorithm zDeadlock.

Slides:



Advertisements
Similar presentations
Chapter 7: Deadlocks.
Advertisements

1 Concurrency: Deadlock and Starvation Chapter 6.
Chapter 6 Concurrency: Deadlock and Starvation Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community.
Chapter 6 Concurrency: Deadlock and Starvation Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community.
Washington WASHINGTON UNIVERSITY IN ST LOUIS Concurrency: Deadlock Detection Fred Kuhns Department.
Concurrency: Deadlock and Starvation Chapter 6. Deadlock Permanent blocking of a set of processes that either compete for system resources or communicate.
Chapter 6 Concurrency: Deadlock and Starvation Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community.
Chapter 6 Concurrency: Deadlock and Starvation Operating Systems: Internals and Design Principles, 6/E William Stallings Dave Bremer Otago Polytechnic,
Concurrency: Deadlock and Starvation Chapter 6. Deadlock Permanent blocking of a set of processes that either compete for system resources or communicate.
MODERN OPERATING SYSTEMS Third Edition ANDREW S
Chapter 6 Concurrency: Deadlock and Starvation
7.5 Deadlock Avoidance The algorithm is simply to ensure that the system will always remain in safe state. Therefore, if a process requests a resource.
Chapter 7: Deadlocks (Continuation). 7.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts - 7 th Edition, Feb 14, 2005 Chapter 7: Deadlocks.
MODERN OPERATING SYSTEMS Third Edition ANDREW S. TANENBAUM Chapter 6 Deadlocks Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All.
Chapter 6 Concurrency: Deadlock and Starvation I
Chapter 6 Concurrency: Deadlock and Starvation
Concurrency: Deadlock and Starvation Chapter 6. Revision Describe three necessary conditions for deadlock Which condition is the result of the three necessary.
1 Chapter 7: Deadlock. 2 The Deadlock Problem System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance.
Concurrency: Deadlock & Starvation
CS 450 OPERATING SYSTEMS DEADLOCKS Manju Muralidharan Priya.
1 Lecture 8: Deadlocks Operating System Spring 2008.
1 M. Bozyigit ICS Operating Systems Deadlock. 2 Deadlock n Permanent blocking of a set of processes that either compete for system resources or communicate.
1 Concurrency: Deadlock and Starvation Chapter 6.
Witawas Srisa-an Chapter 6
CPSC 4650 Operating Systems Chapter 6 Deadlock and Starvation
Deadlock Detection with One Resource of Each Type (1)
1 Concurrency: Deadlock and Starvation Chapter 6.
Chapter 6 Concurrency: Deadlock and Starvation
Deadlocks Gordon College Stephen Brinton. Deadlock Overview The Deadlock Problem System Model Deadlock Characterization Methods for Handling Deadlocks.
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.
Concurrency: Deadlock and Starvation
Chapter 6 Concurrency: Deadlock and Starvation Operating Systems: Internals and Design Principles, 6/E William Stallings Dave Bremer Otago Polytechnic,
Monitors High-level synchronization construct that allows the safe sharing of an abstract data type among concurrent processes. monitor monitor-name {
1 Announcements The fixing the bug part of Lab 4’s assignment 2 is now considered extra credit. Comments for the code should be on the parts you wrote.
Chapter 6 Concurrency: Deadlock and Starvation Operating Systems: Internals and Design Principles, 6/E William Stallings Dave Bremer Otago Polytechnic,
1 Deadlocks Chapter Resource 3.2. Introduction to deadlocks 3.4. Deadlock detection and recovery 3.5. Deadlock avoidance 3.6. Deadlock prevention.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Deadlocks II.
1 MODERN OPERATING SYSTEMS Third Edition ANDREW S. TANENBAUM Chapter 6 Deadlocks Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc.
MODERN OPERATING SYSTEMS Third Edition ANDREW S. TANENBAUM Chapter 6 Deadlocks Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All.
Operating System Chapter 6. Concurrency: Deadlock and Starvation Lynn Choi School of Electrical Engineering.
Chapter 7: Deadlocks. 7.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 7: Deadlocks The Deadlock Problem System Model Deadlock.
Chapter 81 Deadlock Avoidance Technique  Resource Allocation Denial: Grant incremental resource requests if we can prove that this leaves the system in.
Chapter 6 Concurrency: Deadlock and Starvation
Deadlocks Dec 11, 2007 CPE Operating Systems
Chapter 6 Concurrency: Deadlock and Starvation Operating Systems: Internals and Design Principles, 6/E William Stallings.
Informationsteknologi Monday, October 1, 2007Computer Systems/Operating Systems - Class 111 Today’s class Deadlock.
Deadlocks Chapter 6 Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Chapter 6 Concurrency: Deadlock and Starvation Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 7: Deadlocks.
Chapter 7: Deadlocks.
MODERN OPERATING SYSTEMS Third Edition ANDREW S
Concurrency: Deadlock and Starvation
ITEC 202 Operating Systems
Day 17 Deadlock.
Day 18 Deadlock.
Deadlock Permanent blocking of a set of process that compete for system resources or communicate with each other. Conditions that characterizes deadlock.
Chapter 12: Concurrency, Deadlock and Starvation
Deadlocks References text: Tanenbaum ch.3.
Advanced Operating System Fall 2009
Lecture 18: Deadlock: Conditions, Detection and Avoidance (cont.)
Chapter 7 Deadlock.
Deadlocks References text: Tanenbaum ch.3.
Deadlocks Session - 14.
MODERN OPERATING SYSTEMS Third Edition ANDREW S
DEADLOCK.
Operating System 6 CONCURRENCY: MUTUAL EXCLUSION AND SYNCHRONIZATION
Deadlocks References text: Tanenbaum ch.3.
Chapter 7: Deadlocks.
MODERN OPERATING SYSTEMS Third Edition ANDREW S
Presentation transcript:

Chapter 6 Concurrency: Deadlock and Starvation II zDeadlock zConditions for Deadlock zDeadlock Prevention zDeadlock Avoidance zBanker’s Algorithm zDeadlock Detection zStrategies once Deadlock Detected zDeadlock Detection Algorithm zUNIX Concurrency Mechanisms

Deadlock Detection zOperating system checks for deadlock zCheck at resource request yearly detection of deadlock yfrequent checks consume processor time zCheck periodically

Strategies once Deadlock Detected zAbort all deadlocked processes zBack up each deadlocked process to some previously defined checkpoint, and restart all process yoriginal deadlock may occur zSuccessively abort deadlocked processes until deadlock no longer exists zSuccessively preempt resources until deadlock no longer exists

Deadlock Detection Algorithm (1) 1. Mark each process that has a row in the Allocation matrix of all zeros. 2.Initialize a temporary vector W to equal to Available vector. 3. Find an index i such that process i is currently unmarked and the ith row of Q is less than or equal to W. That is, Q ik <= W k, for 1 <= k <= m. If no such row is found, terminate the algorithm. ( Q ik represents the amount of resources of type j requested by process i. m: the amount of resources.) 4. If such a row is found, mark process i and add the corresponding row of the allocation matrix to W. That is, set W k = W k + A ik. Return to step 3. A deadlock exists if and only if there are unmarked processes at the end of the algorithm.

Example for Deadlock Detection (2) - Is there any deadlock? R1 R2 R3 R4 R1 R2 R3 R4 R1 R2 R3 R4 P P P P P Claim Matrix Allocation Matrix Request Matrix C ik A ik Q ik R k = Resource Vector V k = Available Vector

Example for Deadlock Detection (3) - Apply the deadlock detection algorithm Step 1 Mark P4 & P5, because P4 & P5 have no allocated resources. R1 R2 R3 R4 R1 R2 R3 R4 R1 R2 R3 R4 P P P *P *P Claim Matrix Allocation Matrix Request Matrix C ik A ik Q ik R k = Resource Vector V k = Available Vector

Example for Deadlock Detection (4) - Apply the deadlock detection algorithm Step 2 and 3 set W = W k = V k = ( ) R1 R2 R3 R4 R1 R2 R3 R4 R1 R2 R3 R4 P P P *P *P Claim Matrix Allocation Matrix Request Matrix C ik A ik Q ik R k = Resource Vector W =W k = V k = Available Vector

Example for Deadlock Detection (5) - Apply the deadlock detection algorithm Step 4 The request of process P3 is less than or equal to w, so mark P3 and set W = W + A = ( ) + ( ) = ( ) R1 R2 R3 R4 R1 R2 R3 R4 R1 R2 R3 R4 P P *P *P *P Claim Matrix Allocation Matrix Request Matrix C ik A ik Q ik R k = Resource Vector V k = Available Vector

Example for Deadlock Detection (6) - Apply the deadlock detection algorithm Step 3 Can not find a row of Q is less than or equal to W. Terminate. P1 & P2 unmarked, indicating these processes are deadlocked. R1 R2 R3 R4 R1 R2 R3 R4 R1 R2 R3 R4 P P *P *P *P Claim Matrix Allocation Matrix Request Matrix C ik A ik Q ik R k = Resource Vector V k = Available Vector

Question 3 - Exercise/Home Work (1) - Is there any deadlock? R1 R2 R3 R4 R1 R2 R3 R4 R1 R2 R3 R4 P P P P P Claim Matrix Allocation Matrix Request Matrix C ik A ik Q ik R k = Resource Vector V k = Available Vector

UNIX Concurrency Mechanisms zSignals ysoftware mechanism that informs a process of the occurrence of asynchronous events

UNIX Concurrency Mechanisms zPipes ycircular buffer allowing two processes to communicate yqueue written by one process and read by another yoperating system enforces mutual exclusion for writing and reading the pipe ywrite requests are immediately executed if there is room in the pipe, otherwise the process is blocked yread request is blocked if attempts to read more bytes than currently in the pipe

UNIX Concurrency Mechanisms zMessage Queue yblock of text with accompanying type yreceiver can either retrieve messages in FIFO order or by type yprocess suspends when trying to send a message to a full queue yprocess suspends when reading from an empty queue yprocess trying to read a certain type fails, it’s not suspended

UNIX Concurrency Mechanisms zSemaphores ywait and signal yoperating system handles all these requests

UNIX Concurrency Mechanisms zShared memory ycommon block of virtual memory shared by multiple processes yfast form of interprocess communication ymutual exclusion must be provided by the processes, not the operating system

Question 4 - Exercise/Home Work (1) Consider a system with a total of 150 units of memory, allocated to three processes as shown: Process Max Hold Apply the Deadlock Detection and Banker’s algorithm to determine whether it would be safe to grant each of the following requests. If yes, indicate a sequence of termination that could be guaranteed possible. If no, show the reduction of the resulting allocation table. a. A fourth process arrives, with a maximum memory need of 60 and an initial need of 25 units. b. A fourth process arrives, with a maximum memory need of 60 and an initial need of 35 units.