Deadlock Assignment
Deadlock Assignment
Deadlock Assignment
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 (including itself).
P0 P1
System Model
Resource-Allocation Graph
• Process
....
• Pi requests instance of Rj
....
• Pi is holding an instance of Rj
....
Example of a Resource Allocation Graph
Resource Allocation Graph With A Deadlock
Graph With A Cycle But No Deadlock
Deadlock Prevention
Difference from avoidance is that here, the system itself is build in such a way
that there are no deadlocks.
This may however be even more conservative than deadlock avoidance strategy.
Safe State
To avoid deadlocks, we try to make only those transitions that will take
you from one safe state to another. We avoid transitions to unsafe state (a
state that is not deadlocked, and is not safe)
eg.
Total # of instances of resource = 12
(Max, Allocated, Still Needs)
P0 (10, 5, 5) P1 (4, 2, 2) P2 (9, 2, 7) Free = 3
- Safe
The sequence is a reducible sequence
the first state is safe.
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}
}
o m resources, n processes
o Max resources in existence = [E1, E2, E3, .... Em]
o Current Allocation = C1-n,1-m
o Resources currently Available = [A1, A2, ... Am]
o Request matrix = R1-n,1-m
o Invariant = Sum(Cij) + Aj = Ej
o Define A <= B for 2 vectors, A and B, if Ai <= Bi for all i
o Overview of deadlock detection algorithm,
Recovery
o through preemption
o rollback
keep checkpointing periodically
when a deadlock is detected, see which resource is needed.
Take away the resource from the process currently having it.
Later on, you can restart this process from a check pointed
state where it may need to reacquire the resource.
o killing processes
where possible, kill a process that can be rerun from the
beginning without illeffects