Deadlocks Two - Computer Operating Systems - Lecture Slides, Slides of Operating Systems

These lecture slides are very easy to understand the computer operating system. The major points in these lecture slides are:Deadlocks Two, System Model, Deadlock Characterization, Recovery From, Deadlock Detection, Deadlock Avoidance, Deadlock Prevention, Methods For Handling Deadlocks, Completing Their Tasks, Avoiding

Typology: Slides

2012/2013

Uploaded on 04/25/2013

baidehi
baidehi 🇮🇳

4.4

(14)

101 documents

1 / 43

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Lecture 14
Chapter 7: Deadlocks (cont)
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b

Partial preview of the text

Download Deadlocks Two - Computer Operating Systems - Lecture Slides and more Slides Operating Systems in PDF only on Docsity!

Lecture 14

Chapter 7: Deadlocks (cont)

Docsity.com

Chapter 7: Deadlocks

  • The Deadlock Problem
  • System Model
  • Deadlock Characterization
  • Methods for Handling Deadlocks
  • Deadlock Prevention
  • Deadlock Avoidance
  • Deadlock Detection
  • Recovery from Deadlock

Docsity.com

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
  • Example
    • System has 2 disk drives
    • P 1 and P 2 each hold one disk drive and each needs another one
  • Example
    • semaphores A and B , initialized to 1 P 0 P 1 wait (A); wait(B) wait (B); wait(A) Docsity.com

Bridge Crossing Example

  • Traffic only in one direction
  • Each section of a bridge can be viewed as a resource
  • If a deadlock occurs, it can be resolved if one car backs up - preempt resources and rollback Docsity.com

Deadlock Characterization

  • Mutual exclusion: only one process at a time can use a resource
  • Hold and wait: a process holding at least one resource is waiting to acquire additional resources held by other processes
  • No preemption: a resource can be released only voluntarily by the process holding it, after that process has

Deadlock can arise if four conditions hold simultaneously.

necessary^ conditions

sufficient^ condition

Docsity.com

Resource-Allocation Graph

  • V is partitioned into two types:
    • P = { P 1 , P 2 , …, Pn }, the set consisting of all the processes in the system
    • R = { R 1 , R 2 , …, R (^) m }, the set consisting of all resource types in the system
  • request edge – directed edge P 1 → R (^) j
  • assignment edge – directed edge RP

A set of vertices V and a set of edges E.

Docsity.com

Example of a Resource Allocation

Graph

Docsity.com

Basic Facts

  • If graph contains no cycles ⇒ no deadlock
  • If graph contains a cycle ⇒
    • if only one instance per resource type, then deadlock
    • if several instances per resource type, possibility of deadlock

Docsity.com

Methods for Handling Deadlocks

  • Ensure that the system will never enter a deadlock state - deadlock prevention - design decision - deadlock avoidance - runtime decision
  • Allow the system to enter a deadlock state and then recover - deadlock recovery - periodic runtime decision Docsity.com

Deadlock Prevention

  • Mutual Exclusion – not required for sharable resources; - must hold for nonsharable resources - not possible - must always be supported by the O/S
  • Hold and Wait – must guarantee that whenever a process requests a resource, it does not hold any other resources - Require process to request and be allocated all its resources before it begins execution,

Restrain the ways request can be made

Docsity.com

Deadlock Avoidance

  • Simplest and most useful model requires that each process declare the maximum number of resources of each type that it may need
  • The deadlock-avoidance algorithm dynamically examines the resource- allocation state to ensure that there can never be a circular-wait condition - mainly a scheduling problem

Requires that the system has some additional a priori information available

Docsity.com

Safe State

  • When a process requests an available resource, system must decide - if immediate allocation leaves the system in a safe state
  • System is in safe state if there exists a sequence < P 1 , P 2 , …, P (^) n > of ALL the processes is the systems such that - for each Pi , the resources that Pi can still request can be satisfied by currently available resources + resources held by all the Pj , with j < I
  • That is: Docsity.com

Avoidance algorithms

  • Single instance of a resource type
    • Use a resource-allocation graph
  • Multiple instances of a resource type
    • Use the banker’s algorithm

Docsity.com

Resource-Allocation Graph Scheme

  • Claim edge PiR (^) j indicated that process Pj may request resource R (^) j ; represented by a dashed line
  • Claim edge converts to request edge when a process requests a resource
  • Request edge converted to an assignment edge when the resource is allocated to the process Docsity.com