Resource Management: Chap 9 Reusable  Disk blocks  File descriptors  Semaphores Consumable  Messages  Packets.

Slides:



Advertisements
Similar presentations
Chapter 7: Deadlocks.
Advertisements

1 Concurrency: Deadlock and Starvation Chapter 6.
ICS Principles of Operating Systems Lectures 8 and 9 - Deadlocks Prof. Dmitri V. Kalashnikov dvk ics.uci.edu Slides © Prof. Nalini Venkatasubramanian.
Deadlock and Starvation
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.
Concurrency: Deadlock and Starvation Chapter 6. Deadlock Permanent blocking of a set of processes that either compete for system resources or communicate.
6. Deadlocks 6.1 Deadlocks with Reusable and Consumable Resources
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.
Deadlocks CS 3100 Deadlocks1. The Deadlock Problem A set of blocked processes each holding a resource and waiting to acquire a resource held by another.
1 Wednesday, June 28, 2006 Command, n.: Statement presented by a human and accepted by a computer in such a manner as to make the human feel that he is.
1 Lecture 8: Deadlocks Operating System Spring 2008.
1 School of Computing Science Simon Fraser University CMPT 300: Operating Systems I Ch 7: Deadlock Dr. Mohamed Hefeeda.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 7: Deadlocks.
Deadlocks Gordon College Stephen Brinton. Deadlock Overview The Deadlock Problem System Model Deadlock Characterization Methods for Handling Deadlocks.
1 School of Computing Science Simon Fraser University CMPT 300: Operating Systems I Ch 7: Deadlock Dr. Mohamed Hefeeda.
What we will cover…  The Deadlock Problem  System Model  Deadlock Characterization  Methods for Handling Deadlocks  Deadlock Prevention  Deadlock.
Deadlock Characterization
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Deadlocks.
Cosc 4740 Chapter 6, Part 4 Deadlocks. The Deadlock Problem A set of blocked processes each holding a resource and waiting to acquire a resource held.
CHAPTER 8: DEADLOCKS System Model Deadlock Characterization
CS6502 Operating Systems - Dr. J. Garrido Deadlock – Part 2 (Lecture 7a) CS5002 Operating Systems Dr. Jose M. Garrido.
Chapter 8: Deadlocks Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance Deadlock Detection Recovery from Deadlock.
 The Deadlock Problem  System Model  Deadlock Characterization  Methods for Handling Deadlocks  Deadlock Prevention  Deadlock Avoidance  Deadlock.
Resource Management Reusable  Disk blocks  File descriptors  Semaphores Consumable  Messages  Packets.
Dr. Kalpakis CMSC 421, Operating Systems Deadlocks.
Deadlocks System Model RAG Deadlock Characterization
Mi-Jung Choi Dept. of Computer and Science Silberschatz, Galvin and Gagne ©2006 Operating System Principles Chapter 7: Deadlocks.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 7: Deadlocks.
Chapter 8 Deadlocks. Objective System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance Deadlock Detection.
1 CS.217 Operating System By Ajarn..Sutapart Sappajak,METC,MSIT Chapter 6 Deadlocks Slide 1 Chapter 6 Deadlocks.
Chapter 10 Deadlock. What is Deadlock? Two or more entities need a resource to make progress, but will never get that resource Examples from everyday.
Chapter 7: Deadlocks. 7.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 7: Deadlocks The Deadlock Problem System Model Deadlock.
Chapter 7: Deadlocks. 7.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 7: Deadlocks The Deadlock Problem System Model 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);
Deadlock. Examples You can't get a job without experience; you can't get experience without a job. A set of blocked processes each holding a resource.
Chapter 7: Deadlocks.
OPERATING SYSTEM CONCEPTS AND PRACTISE
Process Management Deadlocks.
CSSE 332 Operating Systems Rose-Hulman Institute of Technology
Operating System Concepts
Deadlock Management.
G.Anuradha Ref:- Galvin
Chapter 7: Deadlocks.
Advanced Operating System Fall 2009
Operating System: DEADLOCKS
ICS 143 Principles of Operating Systems
Chapter 7 Deadlock.
Process Deadlocks.
Chapter 7: Deadlocks.
Deadlock B.Ramamurthy CSE421 1/11/2019 B.Ramamurthy.
G.Anuradha Ref:- Galvin
Chapter 7: Deadlocks.
Outline Deadlocks, dead lock prevention, avoidance.
Deadlock Prevention Restrain the ways request can be made.
CSc 552 Advanced Unix Process deadlock deadlock prevention
Deadlock B.Ramamurthy CSE421 2/23/2019 B.Ramamurthy.
DEADLOCK.
Lecture 27 Syed Mansoor Sarwar
Chapter 7: Deadlocks.
Deadlock B.Ramamurthy CSE421 4/23/2019 B.Ramamurthy.
Deadlock B.Ramamurthy CSE421 5/1/2019 B.Ramamurthy.
Chapter 7: Deadlocks.
Chapter 7: Deadlocks.
Deadlock B.Ramamurthy CSE421 8/28/2019 B.Ramamurthy.
Deadlock B.Ramamurthy CSE421 9/3/2019 B.Ramamurthy.
Deadlock CSE 2431: Introduction to Operating Systems
Presentation transcript:

Resource Management: Chap 9 Reusable  Disk blocks  File descriptors  Semaphores Consumable  Messages  Packets

Reusable Data Structures const int M = 10;/* # of resources*/ typedef unsigned int ResourceVec[M]; ResourceVec available, /* # unallocated */ total; /*maximum possible units*/

Reusable Data Structures const int N = 5; /* # of processes*/ typedef struct { ResourceVec allocation, /*owned*/ request, /*unsatisfied requests*/ maxClaim; /*only for batch */ } PerProcess; /*process*/

Resource State Diagram Process Resource avail total 12+(1)+[1] 1 [2] [1] 1+(1)+[1] (1)[1] RESOURCES 3 PROCESSES Process 1 owns 2 units of R1, has requested 1 more with a remaining claim of 1 unit. There are no R1 units avail.

Deadlock No Effective Deadlock A request must be granted in finite time even if new requests are accepted. No Deadlock A request must be granted in finite time assuming that no further requests are accepted.

Effective Deadlock Example Process Resource avail total 1 1+[1] (2)+[2] 1+[1] 0 2 Processes 1 and 3 overlap requests for 1 unit at a time. Process 2’s request for 2 units is never satisfied.

Necessary Conditions (1) Processes claim exclusive control. (2) Processes hold resources while requesting additional resources. (3) Resources cannot be forcibly removed (preempted) from processes. (4) A circular chain of processes exist such that each process holds one or more of the resources requested by its predecessor in the chain. If not, one of the processes would eventually receive a resource that it needed to complete.

Solution Classes Prevention  Static, works before programs execute Avoidance  Dynamic, check every request for safety Detection/Recovery  Check for “stuck” processes at intervals

Prevention No exclusive control -- share everything No incremental requests 1.Collective requests 2.Release all before requesting more Allow preemption Havender’s Ordered Requests request a resource in class C(i) only if it holds no resources in any class C(j), j>=i. Dijkstra’s Minimal Progress

Havender Ordered Request Example Class Resource Type 6 Printer 5 Disk 1 4 Tape Drives 1 and 2 3 Disk 2 2 Tape Drives 3 and 4 1 Memory

Avoidance A request is granted only if it results in a SAFE resource state. Requires Max Claim information. A safe execution sequence is an execution schedule of processes (P1, P2,..., Pn) such that for each P(i), when it begins execution, its maximal claims can be satisfied by the available resources.

A Safe State Process Resource avail total 11+[4] 3+(1)+[4] 3+[3] 3 10 Safe Execution Sequences = (P3, P1, P2) (P3, P2, P1)

An Unsafe State Process Resource avail total 11+(1)+[4] 4+[3] 3+[3] 2 10 NO Safe Execution Sequence exists!

Banker’s Algorithm On every request, search for a SES such that  Every process can have its MAXIMUM CLAIM satisfied in at least one execution order Most Liberal because it gives away all resources if possible at the cost of execution order flexibility

Banker’s Algorithm avail = available; /*copy the current state*/ for (i=0; i<N; i++) canFinish[i]=false; for ( ;; ) { i = 0; allInSES = true; for ( ;; ) { if ( !canFinish[i] ) { /*am I already in SES*/ if (vGeq(avail, i)) { /*no, can I get resources?*/ vAdd(avail, i); /*yes, then I can finish and*/ canFinish[i] = true; /*add resources to "avail"*/ break; /*I am now in the SES*/ } else allInSES = FALSE; /*>=1 is still delayed*/ } /*if*/ if (++i >= N) return allInSES; /*exit with answer*/ } } /*for for*/

Detection and Recovery For single-unit resources (semaphores/files), a cycle is a necessary and sufficient condition for deadlock.

Detection and Recovery Process Resource available total 1 1+(1) 1 (1) (1) A cycle (P1 P2) exists but no deadlock because P4 can terminate and give a resource back.

Recovery Options Terminate operating system Terminate all processes in a cycle Terminate one process in a cycle Preempt resources