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 prevention 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 resuorces.|
|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.|
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Deadlock Prevention And Avoidance
- Introduction to TimeStamp and Deadlock Prevention Schemes in DBMS
- Difference between Deadlock and Starvation in OS
- Deadlock in DBMS
- Deadlock Detection And Recovery
- Deadlock, Starvation, and Livelock
- Deadlock detection in Distributed systems
- Introduction of Deadlock in Operating System
- Deadlock Ignorance in Operating System
- Conditions for Deadlock in Operating System
- Recovery from Deadlock in Operating System
- Deadlock Detection in Distributed Systems
- Hierarchical Deadlock Detection in Distributed System
- Deadlock Detection Algorithm in Operating System
- Program for Deadlock free condition in Operating System
- Chandy-Misra-Haas's Distributed Deadlock Detection Algorithm
- Collision Avoidance in wireless networks
- Zombie Processes and their Prevention
- Difference between MAN and WAN
- Difference between PCI-E and PCI-X
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.