ITFN 2601 Introduction to Operating Systems - PowerPoint PPT Presentation

1 / 17
About This Presentation
Title:

ITFN 2601 Introduction to Operating Systems

Description:

Ostrich Algorithm. Stick your head in the sand and pretend there is no problem at all ... deadlock. RAGs are quite useful. Ostrich algorithm quite popular ... – PowerPoint PPT presentation

Number of Views:85
Avg rating:3.0/5.0
Slides: 18
Provided by: daniels80
Category:

less

Transcript and Presenter's Notes

Title: ITFN 2601 Introduction to Operating Systems


1
ITFN 2601Introduction to Operating Systems
  • Lecture 6
  • Deadlock
  • Deadlock Recovery

2
Agenda
  • What is a Resource?
  • Deadlock Defined
  • Conditions for Deadlock
  • Resource Allocation Graphs
  • Dealing with Deadlock

3
Resources
  • An object granted
  • Hardware (disk, cpu)
  • Piece of Information (memory, record in DB)
  • Preemptable non-preemptable

4
Utilizing a Resource
  • Request resource
  • Use Resource
  • Release resource
  • Use a semaphore/mutex to get/release lock on
    resource

5
Deadlock Defined
  • From our childhood
  • Ive got the ball and want the bat
  • Youve got the bat and want the ball
  • A set of processes is deadlocked if each process
    in the set is waiting for an event that only
    another process in the set can cause.

6
Conditions for Deadlock
  • Mutual exclusion of resource
  • Hold and Wait (processes with a resource can
    request other resources)
  • Non-preemptable resources
  • Circular wait (chain of processes in wait)
  • See RAGs (next slide)

7
Resource Allocation Graphs
  • Figure 3-3

D
A
S
T
U
B
R
C
Process Aholdingresource R
Process Brequestingresource S
Circularity Deadlock
8
Dealing with Deadlock
  • Ostrich Algorithm (today)
  • Detection Recovery (today)
  • Dynamic Avoidance (next lecture)
  • Prevention (next lecture)

9
Ostrich Algorithm
  • Stick your head in the sand and pretend there is
    no problem at all
  • What is the typical use of the system?
  • What is the probability of deadlock?
  • Do the costs associated with dealing w/ deadlock
    outweigh the benefits?

10
Detection Recovery
  • One resource of each type
  • Multiple resource of each type
  • Preemption
  • Rollback
  • Killing Processes

11
Detection (1 resource)
  • Detect cycle in RAG
  • Use a directed graph
  • Utilize an optimized cycle detection algorithm
    speed essential!

12
Detection (multiple resource)
  • Forget about it

13
OK, Now What?
  • Once weve detected deadlock
  • Handle it
  • Preemption
  • Rollback
  • Killing Processes

14
Preemption
  • Not always possible
  • Highly dependant upon the resource
  • Typically associated w/ hardware resources
  • Some examples
  • Suspending a large print job
  • CD-burner

15
Rollback
  • Save the state of each process periodically
    (checkpoint)
  • Restore the process w/ the needed resource to an
    earlier checkpoint (before it acquired the
    resource)
  • Then the resource is now available
  • Drawback rolled back process loses work

16
Killing Processes
  • Again, not always an option
  • DB transactions cannot always be killed midway
    through!
  • Kill process to free up resource

17
Summary
  • Resources can be preeptable nonpreemptable
  • Deadlock can cause processes to halt (stop making
    progress)
  • We can detect deadlock
  • RAGs are quite useful
  • Ostrich algorithm quite popular
Write a Comment
User Comments (0)
About PowerShow.com