Deadlock in Operating System

Deadlock in Operating System 


Definition of Deadlock in OS - A deadlock in an operating system is a situation in which two or more computer programs want to use the same resource to complete their execution. As a result of which both prevent each other from accessing the resource and execution of both stops completely. Deadlock gives rise to a situation when the computer's central processing unit i.e. CPU is neither able to complete the execution of a running program nor start the execution of a new program.

Deadlock in Operating System
Deadlock in Operating System 


Any multiprocessing CPU means a CPU in which two or more processes (meaning any program or instruction given by the user) are executed at the same time. It is very common to have the problem of deadlock, because at any time two or more processes may require resources such as the same data or hardware devices. There are many other reasons for the occurrence of the problem of deadlock in the computer, which we will know in detail later.


When a deadlock condition occurs in a computer, all the work done by that computer stops and the computer is neither able to execute any program nor display any output to the user. The operating system ie OS is responsible for dealing with a deadlock-like situation in the computer. That is why many different algorithms are used in modern operating systems to deal with deadlock situations, which we will read about later.


Condition for Deadlock in OS

Main Reason of Deadlocks in Operating System (OS) in Hindi :- The problem of deadlock in an operating system can be due to the occurrence of any one of the following four conditions. These are also known as Coffman Conditions.


Mutual Exclusion: - A resource can be used by only one program at a time, meaning that no two or more programs can share any resource among themselves.

Hold and Wait: - When a program authorizes the resources which are found while executing and waits for those which are not found, in this situation neither it is able to execute completely nor other programs which It wants to use the resources it has authorized to execute them.

No preemption: - Until the execution of a program is not completed, its resources cannot be used by any other means that the execution of the first program is paused, yet no one else can use its resources.

Circular Wait :- The first program is waiting for the resources authorized by the second program, at the same time the second program is waiting for the resources authorized by the third program and so on, the last program is waiting for the resource authorized by the first process. Thus a circular chain is formed where no program is executed completely.


Deadlock Detection and Handling Methods 

Deadlock Detection by OS  :- The resource scheduler can be used to detect the deadlock by the operating system (OS) because the resource scheduler keeps track of all those resources, which are allocated to different programs or processes. Has been done. Once a deadlock is detected, it can be resolved using the following methods:-


Methods for handling deadlock  :- The problem of deadlock can be dealt with in three ways.


We can take the resources authorized by a program and give it to another, so that the execution of one program is completed before.

In situations where a deadlock is likely to occur, the operating system may periodically record the state of each process and, when a deadlock occurs, terminate and restart the entire process, and at other times allocate resources differently. kind of can do.

We can completely stop or end one or more programs for now, so that the execution of one program is completed.


[Note:- Many times it also happens that the operating system fails to deal with its deadlock situation or it takes too much time to deal with this situation, in such a situation it is better to restart the computer.]


Conclusion on Deadlocks in Operating System:- At first only one program and instructions were executed in the computer at a time. So all the resources of the computer were available for the same program and the problem like deadlock never occurred.


But gradually over time the functionality of the computer was developed and the demand for providing output as quickly as possible according to the commands given by the user started increasing. That is why such CPUs were created in which more than one program and command could be executed at the same time, resulting in deadlock problem.


But all operating systems also have measures to deal with the problem of deadlock, before executing a program at the present time or checking what resources that program is going to require and allowing two or more programs If executed simultaneously, some kind of deadlock may occur. This can prevent deadlock before this problem occurs.


In this article we have tried to explain in simple Hindi language what is deadlock in operating system. Hope you liked this article on Deadlocks in Operating System in Hindi. If you want to take any suggestion related to this, then definitely tell us by writing in the comment box below that we can make necessary changes in our article to make it more useful.

Previous Post Next Post

Contact Form