 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
if
(request[i] > need[i]) {
|
|
|
// error, asked for too much
|
|
|
}
|
|
|
if
(request[i] > available[i]) {
|
|
|
// wait until resources become available
|
|
|
}
|
|
|
// resources are available to satisfy
request, assume
|
|
|
// that we satisfy the request, we would
then have
|
|
|
available
= available – request[i];
|
|
|
Allocation[i]
= allocation[i] + request[i];
|
|
|
need[i] =
need[i] – request[i];
|
|
|
// now check if this would leave us in a
safe state
|
|
|
// if yes then grant the request otherwise
the process
|
|
// must wait
|
|