Difference between Deadlock Prevention and Deadlock Avoidance
1. Deadlock Prevention :
Deadlock prevention means to block at least one of the four conditions required for deadlock to occur. If we are able to block any one of them then deadlock can be prevented.
The four conditions which need to be blocked are:-
- Mutual Exclusion
- Hold and Wait
- No Preemption
- Circular Wait
Spooling and non-blocking synchronization algorithms are used to prevent the above conditions.In deadlock prevention all the requests are granted in a finite amount of time.
2. Deadlock Avoidance :
In Deadlock avoidance we have to anticipate deadlock before it really occurs and ensure that the system does not go in unsafe state.It is possible to avoid deadlock if resources are allocated carefully. For deadlock avoidance we use Banker’s and Safety algorithm for resource allocation purpose. In deadlock avoidance the maximum number of resources of each type that will be needed are stated at the beginning of the process.
Difference between Deadlock Prevention and Deadlock Avoidance :
S.NO. | Factors | Deadlock Prevention | Deadlock Avoidance |
---|---|---|---|
1. | Concept | It blocks at least one of the conditions necessary for deadlock to occur. | It ensures that system does not go in unsafe state |
2. | Resource Request | All the resources are requested together. | Resource requests are done according to the available safe path. |
3. | Information required | It does not requires information about existing resources, available resources and resource requests | It requires information about existing resources, available resources and resource requests |
4. | Procedure | It prevents deadlock by constraining resource request process and handling of resources. | It automatically considers requests and check whether it is safe for system or not. |
5. | Preemption | Sometimes, preemption occurs more frequently. | In deadlock avoidance there is no preemption. |
6. | Resource allocation strategy | Resource allocation strategy for deadlock prevention is conservative. | Resource allocation strategy for deadlock avoidance is not conservative. |
7. | Future resource requests | It doesn’t requires knowledge of future process resource requests. | It requires knowledge of future process resource requests. |
8. | Advantage | It doesn’t have any cost involved because it has to just make one of the conditions false so that deadlock doesn’t occur. | There is no system under-utilization as this method works dynamically to allocate the resources. |
9. | Disadvantage | Deadlock prevention has low device utilization. | Deadlock avoidance can block processes for too long. |
10. | Example | Spooling and non-blocking synchronization algorithms are used. | Banker’s and safety algorithm is used. |
Please Login to comment...