Condition for Deadlock
In the system, the deadlock occurs when the system has these four conditions simultaneously that are as follows:
- Mutual Exclusion
- No-preemption
- Hold & wait
- Circular wait
For a deadlock to occur, all four conditions must be met. The impasse is broken if any one of them is averted or resolved.
Mutual Exclusion
When two people meet on the landings, they cannot just stroll through since there is only enough room for one person. The first prerequisite for the occurrence of the deadlock is to enable only one person (or process) to utilize the step between them (or the resource).
- The resource has to be allocated to only one process, which is freely available.
- There should be a one-to-one relationship between the resource and process.
No-preemption
To overcome the deadlock, just cancel one of the processes and let the others continue. However, the Operating System does not. It provides resources to the processors for as long as the job requires till it is accomplished. As a result, there is no need for a temporary reallocation of resources. It's the third deadlock condition.
- The resource has to be voluntarily released by the process after completing the execution.
- It is not allowed to preempt the resource from the process forcefully.
Hold & wait
Holding occurs when two individuals refuse to retreat and defend their territory. This is the next condition that must be met in order to break the deadlock.
- A process acquires resources piecemeal. While it awaits allocation and assignment of other resources, it holds on to its acquired resources.
- In other words, a process waits for some resources while holding another resource simultaneously.
Circular wait
Circular wait occurs when two persons refuse to retreat and wait for each other to recede so that they can finish their work. It's the final thing that can cause a deadlock. Processes waiting for resources from the others form a circular chain. In that chain, each process holds at least one unit resource, which is demanded by the next process in the chain.
Suppose there exists a set {P0, P1,..., P0} of waiting processes such that the process P0 is waiting for a resource that P1 holds, and the process P1 is waiting for a resource that P2 holds. The resource allocation graph is:
Symbol and representation
The circle will represent the process as
Resources will be represented with rectangle blocks as
If the process P1 is requested a resource, then it is represented as
If the process P1 is holding an instance, then it is represented as
BYJU's Exam Prep Online Classroom Program
Thanks
#DreamStriveSucceed
Comments
write a comment