Necessary Condition for Deadlock in OS

In this tutorial, we will learn about the most important topics in Operating Systems. The topic name is Deadlock. We already know what the damage is caused by the deadlock in the Operating System.

We are going to learn about the Conditions required for the Deadlock to occur in the Operating Systems (OS). Before going into the condition which cause Deadlock, we are going learn about the Deadlock concept and the cause of its occurrence.

Deadlock

In order to run, every process in a system needs a central processing unit (CPU), file storage, input or output devices, etc. The process has the resource and is released when the process holding a resource's execution is complete. On the other hand, when more processes run concurrently on a system, competition for these resources increases. This might result in a deadlock.

Deadlocks occur when several processes are impeded by the possession of a resource and the need for wait about a resource that must be acquired by another process. As a result, none of the processes are run.

Deadlock is an infinite process

This might cause Deadlock Problem.

Disadvantages in Deadlock

  1. Deadlock is an infinite Process. There is only detection, resolution, prevention techniques. But, there is no Deadlock stopping techniques.
  2. The Process Waiting for the Process

Conditions Required for Deadlock in Operating Systems (OS)

There are four conditions because of which Deadlock is going to occur in Operating Systems. The Conditions are:

  1. Hold and Wait
  2. No Pre Emption
  3. Mutual Exclusion
  4. Circular Wait

Now, let us explain about each and every Condition in detail.

Hold and Wait

Now, let us understand how Hold and Wait is going to cause Deadlock in Operating Systems.

Hold and Wait is process where a process stops a resource from sharing the resource to anyone or any process. Because of this holding, the processes tend to come into or enter waiting state. So, because of this waiting state the processes stop executing.

If the process is holding the resource for infinite time, then the waiting also goes for infinite time. So, the processes behind the waiting process also tend to get into waiting state. Due to this constant waiting state of processes, the condition named Deadlock is going to occur for all the processes which are waiting state.

This is all about Hold and Wait Condition in Deadlock causing condition.

No Pre Emption

Now, let us understand about the condition named No Pre Emption which is going to cause Deadlock in the Operating Systems.

First, let us understand what a Pre Emption is.

When a process transitions from the running state to the ready state or from the waiting state to the ready state, Pre Emption is employed. The resources, mostly CPU cycles, are given to the process for a set period of time before being removed; if the process still has CPU burst time left, it is then put back in the ready queue. Until it has its subsequent opportunity to run, the process remains in the ready queue.

Here, because of absence of Pre Emption the processes get executed till the completion of process. Suppose, if the process which is being executed at this point of time is very big process. Let us assume that the big process takes infinite time to finish.

According to the Non Pre Emptive Approach, a process cannot be skipped until the process is completed. So, the big process which is running now is going to take infinite time to complete its execution. But, until then all the processes have to wait in the Ready Queue to get its turn. This infinite waiting causes the syndrome of Deadlock in the Operating System.

Mutual Exclusion

Now, let us understand what Mutual Exclusion is and how Mutual Exclusion is going to cause Deadlock in the Operating System.

  • Mutual Exclusion is the process by which only a single process is allowed to access the resources present in the Operating System.
  • If this condition is going on in the Operating System, the Hold and Wait condition occurs.
  • So, due to this Infinite waiting might occur and this is going to cause Deadlock to the Process Executed in the Operating System.

Circular Wait.

Circular Wait is the condition where the one process depends upon the other processes and cause deadlock in the Operating System.






Latest Courses