Deadlocks - 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, Deadlock Problem, System Model, Deadlock Characterization, Methods For Handling Deadlocks, Deadlock Prevention, Deadlock Avoidance, Deadlock Detection, Recovery From Deadlock, Develop

Typology: Slides

2012/2013

Uploaded on 04/25/2013

baidehi
baidehi 🇮🇳

4.4

(14)

101 documents

1 / 21

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Lecture 13
Chapter 7: Deadlocks
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15

Partial preview of the text

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

Lecture 13

Chapter 7: Deadlocks

Chapter 7: Deadlocks

• The Deadlock Problem

• System Model

• Deadlock Characterization

• Methods for Handling Deadlocks

• Deadlock Prevention

• Deadlock Avoidance

• Deadlock Detection

• Recovery from Deadlock

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)

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
  • Several cars may have to be backed up if a deadlock occurs
  • Starvation is possible
  • Note : Most OSes do not prevent or deal with deadlocks

Happy scheduling 1  Illustration of a deadlock — scheduling path 1   Q executes everything before P can ever get A  when P is ready, resources A and B are free and P can proceed

Process Q

Get B ... Get A ... Release B ... Release A ... A required B required B required A required

Process P

Get A ... Get B ... Release A ... Release B ... Deadlock Principles

Happy scheduling 2  Illustration of a deadlock — scheduling path 2   Q gets B and A, then P is scheduled; P wants A but is blocked by A’s mutex; so Q resumes and releases B and A; P can now go

Process Q

Get B ... Get A ... Release B ... Release A ... A required B required B required A required

Process P

Get A ... Get B ... Release A ... Release B ... Deadlock Principles

Joint progress diagram Stallings, W. (2004) Operating Systems: Internals and Design Principles (5th Edition). Deadlock Principles

 Deadlocks depend on the program and the scheduling  program design  the order of the statements in the code creates the “landscape” of the joint progress diagram  this landscape may contain gray “swamp” areas leading to deadlock  scheduling condition  the interleaved dynamics of multiple executions traces a “path” in this landscape  this path may sink in the swamps Deadlock Principles

Joint progress diagramno swamp area: there exists no path leading to deadlock (^) Stallings, W. (2004) Operating Systems: Internals and Design Principles (5th Edition). Deadlock Principles

System Model

• Resource types R

, R

,.. ., R

m

CPU cycles, memory space, I/O devices

• Each resource type R

i

has W

i

instances.

• Each process utilizes a resource as

follows:

– request

– use

– release

Resource-Allocation Graph

• V is partitioned into two types:

– P = { P

1

, P

2

, …, P

n

}, 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

→ R

j

• assignment edge – directed edge R → P

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

Resource-Allocation Graph (Cont.)

• Process

• Resource Type with 4 instances

• P

i

requests instance of R

Pi j

Pi Rj Rj

Resource Allocation Graph With A Deadlock

Graph With A Cycle But No

Deadlock