Deadlock Prevention and Avoidance
Deadlock Prevention and Avoidance
AVOIDANCE
Deadlock Prevention
Restrain the ways request can be made.
Mutual Exclusion – not required for sharable resources;
must hold for nonsharable resources.
Preempted resources are added to the list of resources for which the
process is waiting.
Process will be restarted only when it can regain its old resources, as
well as the new ones that it is requesting.
Circular Wait – impose a total ordering of all resource types, and require
that each process requests resources in an increasing order of
enumeration.
Deadlock Avoidance
Simplest and most useful model requires that each process
declare the maximum number of resources of each type that
it may need.
Sequence <P1, P2, …, Pn> is safe if for each Pi, the resources that Pi
can still request can be satisfied by currently available resources +
resources held by all the Pj, with j<i.
If Pi resource needs are not immediately available, then Pi can
wait until all Pj have finished.
When Pj is finished, Pi can obtain needed resources, execute,
return allocated resources, and terminate.
When Pi terminates, Pi+1 can obtain its needed resources, and so
on.
Basic Facts