Unit 4 Deadlock
Unit 4 Deadlock
Avial = (0,0,0)
Neither we are having any resource available in the system
nor a process going to release. Each of the process needs at
least single resource to complete therefore they will
continuously be holding each one of them.
We cannot fulfill the demand of at least one process using the
available resources therefore the system is deadlocked as
Resource-Allocation Graph (Cont.)
Process
Pi requests instance of Rj
Pi
Rj
Pi is holding an instance of Rj
Pi
Rj
Resource Allocation Graph With A Deadlock
Before P3 requested an After P3 requested an
instance of R2 instance of R2
Graph With A Cycle But No Deadlock
(process) and give it to the other process with the expectation that it
will complete the execution and will release this resource sooner.
Well, choosing a resource which will be snatched is going to be a bit
difficult.
Rollback to a safe state
System passes through various states to get into the deadlock state.
The operating system can rollback the system to the previous safe
state. For this purpose, OS needs to implement check pointing at
every state.
The moment, we get into deadlock, we will rollback all the
allocations to get into the previous safe state.
For Process
Kill a process
Killing a process can solve our problem but the
bigger concern is to decide which process to kill.
Generally, Operating system kills a process which
has done least amount of work until now.
Kill all process
This is not a suggestible approach but can be