you can download Linux from here and learn Introduction of Deadlock in Operating System and Introduction of Deadlock in Operating System is a most important topic in Linux. so please read carefully Introduction of Deadlock in Operating System.

In a multiprogramming environment, several processes may compete for a
finite number of resources.

A process requests resources; and if the resources are not available at that
time, the process enters a waiting state.

Sometimes, a waiting process is never again able to change state, because the resources it has requested are held by other waiting processes.

A system consists of a finite number of
number of competing processes. Memory space, CPU cycles, files, and I/O devices are examples of resource

If a system has two CPUs, then the resource type CPU has two instances. If a process requests an instance of a resource type, the allocation of any instance of the type will satisfy the request.

A process must request a resource before using it and must release the
resource after using it.

A process may request as many resources as it requires to carry out its
designated task.

The number of resources requested may not exceed the total number of
resources available in the system

Under the normal mode of operation, a process may utilize a resource in only
the following sequence:

Request: if the request cannot be granted immediately, then the requesting
process must wait until it can acquire the resource.

Use: the process can operate on the resource.

Release: the process releases the resource.

Conditions for Deadlock

A deadlock situation can arise if the following four conditions hold
simultaneously in a system:

  1. Mutual exclusion: at least one resource must be held in a non-sharable mode;
    that is,

only one process at a time can use the resource

If another process requests that resource, the requesting process must be
delayed until

2) Hold and Wait: a process must be holding at least one resource and waiting to
acquire additional resources that are currently being held by other processes.

3) No preemption: Resources that is, a resource can be
released only voluntarily by the process holding it, after that process has
completed its task.

4) Circular wait: a set { P0,P1,…..,Pn} of waiting processes must exist such that P0
is waiting for a resource held by P1, P1 is waiting for a resource held by P2,….,
Pn-1 is waiting for a resource held by Pn, and Pn is waiting for a resource held by

We emphasize that all four conditions must hold for a deadlock to occur.

Deadlock Prevention

Deadlock prevention provides a set of methods for ensuring that at least one of
the necessary conditions for deadlock cannot hold.

Mutual Exclusion: the mutual-exclusion condition must hold for non-sharable

Sharable resources do not require mutually exclusive access and thus cannot

Read only files are good example of a sharable resource.

If several processes attempt to open it at same time, they can be granted
simultaneous access to the file.

A process never needs to wait for a sharable resource.

In general, we cannot prevent deadlocks by denying the mutual-exclusion
condition, because some resources are intrinsically non-sharable.

Hold & Wait:

To ensure that the hold and wait condition never occurs in the system, we must
guarantee that, whenever a process requests a resource, it does not hold any
other resources.

One protocol that can be used requires each process to request and be
allocated all its resources before it begins execution.

An alternative protocol allows a process to request resources only when it has
none. A process may request some resources and use them.

Before it can request any additional resources, however, it must release all the

for more learning click here:-

thank you!

By Sharma

Leave a Reply

Your email address will not be published. Required fields are marked *