Unit-3 Deadlock Class
Unit-3 Deadlock Class
System Model
Deadlock Characterization
Methods for Handling Deadlocks
Deadlock Prevention
Deadlock Avoidance
Deadlock Detection
Recovery from Deadlock
Example
P1 and P2 each hold one tape drive and each needs another one.
process holding it, after that process has completed its task.
P = {P1, P2, …, Pn}, the set consisting of all the processes in the system.
R = {R1, R2, …, Rm}, the set consisting of all resource types in the
system.
Process
Pi requests instance of Rj
Pi
Rj
Pi is holding an instance of Rj
Pi
Rj
deadlock.
state.
recover.
Mutual Exclusion – not required for sharable resources; must hold for
nonsharable resources.
Require process to request and be allocated all its resources before it begins
starvation possible.
Deadlock Prevention (Cont.)
No Preemption –
If a process that is holding some resources requests another resource that cannot be
immediately allocated to it, then all resources currently being held are released.
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
processes.
resource.
to a claim edge.
Multiple instances.
Work = Available
4. If Finish [i] == true for all i, then the system is in a safe state .
Resource-Request Algorithm for Process Pi
Request = request vector for process Pi. If Requesti [j] = k then process Pi wants k instances of
1. If Requesti Needi go to step 2. Otherwise, raise error condition, since process has exceeded its
maximum claim.
2. If Requesti Available, go to step 3. Otherwise Pi must wait, since resources are not available.
Detection algorithm
Recovery scheme
Sequence <P0, P2, P3, P1, P4> will result in Finish[i] = true for all i.
How long process has computed, and how much longer to completion.
what types of resources the process has used (for example,whether the resources are
simple to preempt)
How many more resources the process needs in order to complete