The operating system is nothing but the system program which loads into the memory first and then provides the environment for other users program to run their own program.
In this post, we talk about the deadlock in the operating system.
Deadlock prevention in the Operating system is more preventive and conservative.
Let’s atrt with the basics.
We take care of eliminating any deadlock causing condition:
Now for deadlock prevention what we do is don’t let our system to do anyone of this.
In this, we look at every single resource request and decide whether to allow that request to process. The action will be taken before occurring deadlock.
Deadlock can be avoided by the Bankers Algorithm. It is a resource allocation algorithm developed and designed by Edsger Dijkstra.
This is one of the very common deadlock interview questions that has been asked in many interviews.
Many get confused over Deadlock prevention Vs Deadlock Avoidance in the Operating system.
Let’s try to understand it by considering the analogy. It will be easy.
Now take an example of protection from viral through the water. In a scenario like a deadlock prevention, we would not let one drink water. In the scenario of deadlock avoidance, we would first filter out water.
So in clear-cut words, deadlock prevention is more preventive and conservative. Conservative in the way that, it would decrease the power of the system by not allowing mutual exclusion, etc…
Editors’ Note: This article is written and shared by Madhav Purohit. He is alumni of IIT, Kanpur.