Deadlock in Operating system | Explained

MayhemCode
CodeX
Published in
2 min readJul 13, 2021

A deadlock is a state where all the processes in the deadlock are blocked by each other or waits for each other by holding the resources.

Let’s see Why deadlock occurs, What are the conditions for deadlock, and how to prevent it.

What is Deadlock?

In an operating system, resources might not be unlimited or can be used by one process at a time. To increase the speed of the process some hold the resources before getting the CPU cycles and also need some other process that is in execution. But the Tragic change happens here what if the process in the execution also needs some process that was kept hold by the previous process. Here we can see a lock which is made between the process of how they wait for each other and the CPU stills idle. This process can sometimes lead to serious issues when they are stuck infinitely holding the resources which may lead to the waiting for other processes also. A classic example can be seen in real life like road traffic where vehicles are coming in from both sides but when vehicles come from either side simultaneously then both vehicles will be stuck on the road and also block other vehicles.

Nowadays operating systems are capable of storing multiple processes in the main memory. So the processes hold their resources before even getting CPU cycles which can cause a Deadlock. And also if there is no way to preempt the process solving a deadlock becomes harder. Let’s see the necessary condition by which we can say whether a system is in a deadlock or not. There are 4 ways to recognize this.

For more info on Deadlock handling and conditions visit

https://www.mayhemcode.com/2021/07/deadlock-in-operating-system-explained.html

Originally published at https://mayhemcode.blogspot.com on July 13, 2021.

--

--

MayhemCode
CodeX
Writer for

Blogs on Daily Tech, Science, Crypto and Computer_Science related Stuff