Concurrency: Deadlock & Starvation

Slides:



Advertisements
Similar presentations
Chapter 7: Deadlocks.
Advertisements

1 Concurrency: Deadlock and Starvation Chapter 6.
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.
1 Concurrency: Deadlock and Starvation Chapter 6.
Concurrency: Deadlock and Starvation Chapter 6. Deadlock Permanent blocking of a set of processes that either compete for system resources or communicate.
Lecture 6 :Deadlocks. Deadlock Permanent blocking of a set of processes that either compete for system resources or communicate with each other Involves.
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.
Lecture 7: Deadlock     Necessary Conditions for Deadlock     Deadlock Prevention - Havender's Linear Ordering Deadlock Avoidance Deadlock Detection &
Chapter 6 Concurrency: Deadlock and Starvation
Chapter 6 Concurrency: Deadlock and Starvation
Chapter 81 Deadlock is:  A set of blocked processes each holding a resource and waiting to acquire a resource held by another process in the set.  Example.
Chapter 6 Concurrency: Deadlock and Starvation I
Concurrency : Deadlock and Starvation
1 Concurrency: Deadlock and Starvation Chapter 6.
Chapter 6 Concurrency: Deadlock and Starvation
CSI 400/500 Operating Systems Spring 2009 Lecture #17 –Deadlocks Wednesday, April 15 th.
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.
CS 450 OPERATING SYSTEMS DEADLOCKS Manju Muralidharan Priya.
The ‘deadlock’ conditions Reviewing some key points concerning the potential for ‘deadlock’ in an operating system.
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.
OS Spring 2004 Concurrency: Principles of Deadlock Operating Systems Spring 2004.
Witawas Srisa-an Chapter 6
CPSC 4650 Operating Systems Chapter 6 Deadlock and Starvation
OS Fall’02 Concurrency: Principles of Deadlock Operating Systems Fall 2002.
1 Concurrency: Deadlock and Starvation Chapter 6.
Chapter 6 Concurrency: Deadlock and Starvation
Understanding Operating Systems Sixth Edition
1 School of Computing Science Simon Fraser University CMPT 300: Operating Systems I Ch 7: Deadlock Dr. Mohamed Hefeeda.
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,
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.3. The ostrich algorithm 3.4. Deadlock detection and recovery 3.5. Deadlock avoidance.
Operating System Chapter 6. Concurrency: Deadlock and Starvation Lynn Choi School of Electrical Engineering.
CS6502 Operating Systems - Dr. J. Garrido Deadlock – Part 2 (Lecture 7a) CS5002 Operating Systems Dr. Jose M. Garrido.
CIS Operating Systems Deadlock Professor Qiang Zeng Fall 2015.
Deadlock Operating Systems: Internals and Design Principles.
Chapter 6 Concurrency: Deadlock and Starvation
Chapter 6 Concurrency: Deadlock and Starvation Operating Systems: Internals and Design Principles, 6/E William Stallings.
Chapter 8 Deadlocks. Objective System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance Deadlock Detection.
Silberschatz, Galvin and Gagne ©2009 Edited by Khoury, 2015 Operating System Concepts – 9 th Edition, Chapter 7: Deadlocks.
Informationsteknologi Monday, October 1, 2007Computer Systems/Operating Systems - Class 111 Today’s class Deadlock.
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 6 Concurrency: Deadlock and Starvation Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community.
Concurrency: Deadlock and Starvation
ITEC 202 Operating Systems
Deadlock and Starvation
Chapter 12: Concurrency, Deadlock and Starvation
Deadlock B.Ramamurthy CSE421 9/17/2018 B.Ramamurthy.
Advanced Operating System Fall 2009
CHAPTER 6: Concurrency - Deadlock and Starvation
Chapter 7 Deadlock.
Chapter 7: Deadlocks.
Deadlocks Session - 13.
DEADLOCK.
Operating System 6 CONCURRENCY: MUTUAL EXCLUSION AND SYNCHRONIZATION
Deadlock B.Ramamurthy CSE421 4/26/2019 B.Ramamurthy.
Deadlock B.Ramamurthy CS421 5/4/2019 B.Ramamurthy.
1 DEADLOCK AND STARVATION A Seminar Slide Presentation by CHUKWUEMEKA, UGONNA G. CHUKWUEMEKA, UGONNA G. Dr E.O Bennett (Course Lecturer) CSS Operating.
Presentation transcript:

Concurrency: Deadlock & Starvation Chapter summary: (Chapter 6) Principles of deadlock & starvation problem Three common approaches to deal with deadlock: prevention, detection, and avoidance Dining philosophers problem Deadlock is defined as the permanent blocking of a set of processes that either compete for system resources or communicate with each other. All deadlocks involve conflicting needs for resources by two or more processes.

Reusable & Consumable Resources A reusable resources is one that can be safely used by only one process at a time and is not depleted by that use. Reusable resources: processors, I/O channels, main and secondary memory, devices, and data structures such as files, databases, and semaphores. D = a disk file; T = a tape drive. P1 P2 repeat repeat Request(D); Request(T); Request(T); Request(D); Release(T); Release(D); Release(D); Release(T); Forever; Forever; One solution for the above is to impose constraints on system design concerning the order in which resources are requested.

Reusable & Consumable Resources (continue) Main memory available = 200 KB; P1 P2 Request 80 KB Request 70 KB Request 60 KB Request 80 KB Solution: use virtual memory (Chapter 7) A consumable resource is one that can be created (produced) and destroyed (consumed). Consumable resources: interrupts, signals, messages, and information in I/O buffers. Deadlock occurs if the Receive is blocking. Receive(P2, M); Receive(P1, Q); Send(P2, N); Send(P1, R); Table 5.1 summarizes the key elements of the most important approaches that have been developed: prevention, detection, & avoidance.

The Conditions for Deadlock Three conditions of policy must be present for it to be possible for a deadlock to occur: Mutual exclusion: Only one process may use a resource at a time. Hold-and-wait: A process may hold allocated resources while awaiting assignment of others. No preemption: No resource can be forcibly removed from a process holding it. Deadlock can exist with these three conditions but may not exist with only these conditions. For deadlock actually to take place, a fourth condition is required: Circular wait: A closed chain of processes exists, such that each process holds at least one resource needed by the next process in the chain.

Deadlock Prevention To design a system in such a way that the possibility of deadlock is excluded a priori. Two methods: 1) indirect way to prevent the occurrence of one of the three conditions; 2) direct way to prevent the occurrence of a circular wait; Mutual Exclusion: If you need it, you cannot prevent it! Hold-and-Wait: Request all the resources at one time and blocking the process until all request can be granted simultaneously. This is inefficient: 1) a process may be held up for a long time, waiting for all its resources request to be filled, while instead it can start with some of its resources; 2) resources may remain used for a long time, but cannot be used by other processes.

Deadlock Prevention (continue) No Preemption: 1) If a process holding certain resources is denied a further request, that process must release its original resources and if necessary request them again, together with the additional resource; 2) if a process requests a resource that is currently held by another process, the OS may preempt the second process and require it to release its resources; This approach is practical only when applied to resources whose states can be easily saved and restored later, as in the case with a processor. Circular Wait: By defining a linear ordering of resources types. If a process has been allocated resources of type R, then it may subsequently request only those resources of type following R in the ordering. As with Hold-and-Wait prevention, circular wait prevention may be inefficient, slowing down processes and denying resource access unnecessarily.

Deadlock Detection Deadlock prevention strategies are conservative. They solve the deadlock problem by limiting access to resources and by imposing restrictions on processes. Deadlock detection strategies do not limit resource access or restrict process actions. Request are granted whenever possible. The OS perform an algorithm to detect the circular wait condition periodically. Once deadlock has been detected, some strategy is needed for recovery. The following are possible approaches: 1. Abort all deadlocked processes. 2. Back up each deadlocked process to some previously defined checkpoint, and restart all processes. 3. Successively abort deadlocked processes until deadlock no longer exists. 4. Successively preempt resources until deadlock no longer exists. Note: For 3 & 4, the selection criterion could be: 1) least processor time consumed; 2) least number of lines of output produced; 3) most estimated remaining time; 4) least total resources allocated; 5) lowest priority

Deadlock Avoidance Deadlock avoidance allows the three necessary conditions but makes judicious choices to assure that the deadlock point is never reached. Two approaches to deadlock avoidance: Do not start a process if its demands might lead to deadlock Do not grant an incremental resource request to a process if this allocation might lead to deadlock Process Initiation Denial: All resources are either allocated or available No process can claim more than the total amount of resources in the system No process is allocated more resources of any type than the process originally claimed to need A process is started only if the maximum claim of all current processes plus those of the new process can be met.

Deadlock Avoidance (continue) Resource Allocation Denial: Referred to as Banker's algorithm. Safe and Unsafe state: A safe state is a state in which there is at least one order in which all the processes can be run to completion without resulting in a deadlock. An unsafe state is a state that is not safe!! Resource is granted to a process only if such allocation leads the system to a safe state. Otherwise, the resource will not be granted and the process blocked. (Refer to Figure 6.6 & 6.7) Disadvantages: The Max. resources requirement for each process must be stated in advance. The processes under consideration must be independent; There must be a fixed number of resources to allocate and a fixed number of processes.

An Integrated Deadlock Strategy Group resources into a number of different resource classes. Use linear ordering strategy for the prevention of circular wait. Within a resource class, use the algorithm that is most appropriate for that class. Categorized resources into the following classes: Swappable space: Block of memory on sec. storage. Process resources: Assignable devices, such as tape drives, and files. Main memory: Assignable in pages or segments to processes. Internal resources: I/O channels. Strategy for each class: Swappable space: Prevention -- requiring that all the required resources be allocated at one time. Process resources: Avoidance -- since resources required are usually declared ahead of time. Main memory: Prevention by preemption. When a process is preempted, it is simply swapped to sec. memory, freeing space to resolve the deadlock. Internal resources: Prevention by means of resources ordering can be used.