Banker's Algorithm for Deadlock Avoidance

When a request is made, check to see if after the request is satisfied, there is a (at least one!) sequence of moves that can satisfy all the requests. that  is, the new state is safe. If so, satisfy the request, else make the request wait.

How do you find if a state is safe:      

For example if given n processes and m resources
Max[n * m]
    Allocated[n * m]
    Still_Needs[n * m]
Available[m]
    Temp[m]
 Done[n]
 
while () (Temp[j]=Available[j] for all j
   Find an i such that 
       a) Done[i] = False
       b) Still_Needs[i,j] <= Temp[j]
   if so { Temp[j] += Allocated[i,j] for all j
       Done[i] = TRUE}
   }
   else if Done[i] = TRUE for all i then state is safe
   else state is unsafe
}

(Taken from: http://carbon.cudenver.edu/~dkumar/CSC3453/Lec_figures/ch8_class_notes.pdf  )

Detection and Recovery process

Is there a deadlock currently?

One resource of each type (1 printer, 1 plotter, 1 terminal etc.)

Multiple resources of each type:

          [ Basic idea, is that there is at least 1 execution which will un-deadlock the system ]

Recovery:

 Further information could be searched on the following websites.

                                                               

                                           Go back to page 16

    Designed by: Harriet B. Nyakaana