Deadlock Avoidance (brief) - PowerPoint PPT Presentation

About This Presentation
Title:

Deadlock Avoidance (brief)

Description:

HW #4 is due Tuesday March 8, 11 am. extra office hours Monday March 7, 2 pm ... Algorithm, I've decided not to include it in the s pre-midterm, and it ... – PowerPoint PPT presentation

Number of Views:31
Avg rating:3.0/5.0
Slides: 11
Provided by: Richa149
Category:

less

Transcript and Presenter's Notes

Title: Deadlock Avoidance (brief)


1
Deadlock Avoidance (brief)
  • CSCI 3753 Operating Systems
  • Spring 2005
  • Prof. Rick Han

2
Announcements
  • HW 4 is due Tuesday March 8, 11 am
  • extra office hours Monday March 7, 2 pm
  • PA 2 assigned, due Thursday March 17 1155 pm
  • Midterm is Thursday March 10
  • covers chapter 1-10
  • Midterm review is Tuesday March 8
  • Read chapter 10

3
From last time...
  • We discussed
  • Deadlock Avoidance
  • Is the system in a safe state? Finding a safe
    sequence
  • Bankers (Safety) Algorithm
  • 4 steps, iterative
  • An example was given
  • Lets finish up the examples

4
Deadlock Avoidance
  • Bankers Algorithm determines whether the system
    is in a safe state
  • Suppose we have a new request, and the current
    system is in a safe state
  • Should we grant the new request?
  • Yes, if it leaves the system in a safe state.

5
Deadlock Avoidance
  • Resource-Request Algorithm associated with the
    Bankers Algorithm
  • Let Requesti be a new request vector for
    resources for process Pi
  • If Requesti Needi , go to step 2. Else, the
    new request exceeds the maximum claim. Exit.
  • If Requesti Available, go to step 3. Else,
    process Pi must wait because there arent enough
    available resources
  • Temporarily modify Availablej, Needi,j, and
    Alloci,j
  • Avail - Requesti
  • Alloci Requesti
  • Needi - Requesti
  • Execute the Bankers Safety algorithm to see if
    the system is in a safe state. If so, grant the
    request and permanently update Avail, Need, and
    Alloc. If not, Pi must wait for more resources
    to be freed before Requesti can be granted.
    Restore the old state.

6
Deadlock Avoidance
  • Example 3 from previous lecture
  • 3 resources (A,B,C) with total instances
    available (10,5,7)
  • 5 processes
  • At time t0, the allocated resources Alloci,j,
    Max needs Maxi,j, and Available resources
    Availj, are

P0 P1 P2 P3 P4
Bankers Algorithm found that this was in a safe
state, with safe sequence ltP1, P3, P4, P2, P0gt
7
Deadlock Avoidance
  • Suppose we have a new request from process P1,
    Request1 lt1,0,2gt.
  • Can the system satisfy this request without
    becoming unsafe? Execute the Resource-Request
    Algorithm.
  • Request1 Need1 lt1,2,2gt
  • Request1 Available lt3,3,2gt
  • Temporarily recompute Avail, Need, and Alloc
  • see next slide

8
Deadlock Avoidance
temporarily modified
P0 P1 P2 P3 P4
  • Execute Bankers Algorithm on this revised state.
    We find that the sequence ltP1,P3,P4,P0,P2gt is
    safe.
  • Thus we can grant the Request1 immediately, and
    permanently update the matrices and vectors.

9
Deadlock Avoidance
  • Given this new state, suppose we have a 2nd
    request
  • from P4, such that Request4 lt3,3,0gt. Show that
    this cannot be granted because
  • Request4 Available lt2,3,0gt.
  • That is, there are not enough available
    resources.
  • from P0, such that Request0 lt0,2,0gt. Show that
    this cannot be granted because no safe sequence
    can be found.

10
Deadlock Detection
  • Though I discussed in class a somewhat
    sophisticated deadlock detection algorithm that
    is similar to the Bankers Algorithm, Ive
    decided not to include it in the slides
    pre-midterm, and it wont be covered on the
    midterm
Write a Comment
User Comments (0)
About PowerShow.com