0% found this document useful (0 votes)
19 views4 pages

Aneesh Banerjee - 56

Uploaded by

Dilip Das
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views4 pages

Aneesh Banerjee - 56

Uploaded by

Dilip Das
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

GROUP OF INSTITUTIONS

NAME : ANEESH BANERJEE


UNIVERSITY ROLL NO : 25330823056
UNIVERSITY REG. NO : 232530120236
STREAM : CSE (Ai-Ml)
YEAR : 3RD
SEMESTER : 5th
SUBJECT NAME : OPERATING SYSTEMS

SUBJECT CODE : PCC-CS502

TOPIC: Deadlock
Deadlock
When two or more processes in a computer system are stuck waiting for each other to release
a resource, it's known as a deadlock.

How Does Deadlock occur in the Operating System?


A process in an operating system uses resources in the following way.

 Requests a resource
 Use the resource
 Releases the resource

In operating systems, a scenario arises when two or more processes have some resources and
wait for other processes to hold other resources (s). For instance, in the figure below, process
2 is waiting for resource 1, while process 1 is keeping resource 1 and holding it until process
2 acquires it.

This can be pictured as a dead end where nothing can be done. In multi-threaded and
distributed systems, where resource sharing is prevalent, deadlocks are especially
problematic.

The four necessary conditions for a deadlock to occur are:

1. Mutual Exclusion: It is necessary to hold at least one resource in a non-shareable


mode. If the resource is requested by another process, it has to wait for the resource to
be released before proceeding.
2. Hold and Wait: A process has to have at least one resource in its possession while it
waits to obtain other resources that other processes are now holding.

1|Pa ge
3. No Pre-emption: Resources must be released willingly by the processes holding
them; they cannot be grabbed by force.
4. Circular Wait: There must be a set of processes such that they create a circular chain
where each process waits for a resource held by the next in the set.

Deadlock Avoidance
Making sure the system never reaches a dangerous condition where a deadlock could happen
is known as deadlock avoidance. This is accomplished by dynamically assessing the
condition of resource allocation and taking appropriate action to prevent possible deadlocks.
Edgar Dijkstra created the well-known deadlock avoidance algorithm known as the Banker's
Algorithm. It functions by mimicking resource allocation and guaranteeing that there is
always a safe resource allocation sequence that permits all processes to finish without
experiencing a deadlock. The following are checked by the algorithm:Maximum Need: The
maximum number of resources each process may request.

 Current Allocation: The number of resources currently allocated to each process.


 Available Resources: The number of resources currently available in the system.

By ensuring that the system remains in a safe state, deadlock avoidance prevents the
occurrence of deadlocks.

Deadlock Prevention
In order to avoid deadlocks, deadlock prevention attempts to guarantee that at least one of
the prerequisites for a deadlock cannot hold. There are several ways to accomplish this:

1. Mutual Exclusion: Make resources shareable wherever possible. For example, read-
only files can be shared among multiple processes.
2. Hold and Wait: Require processes to request all the resources they need at once,
before starting execution. This can lead to low resource utilization but prevents
deadlocks.
3. No Pre-emption: Allow pre-emption of resources. If a process holding some
resources requests another resource that cannot be immediately allocated, all resources
currently held by the process are pre-empted and added to the list of available
resources.
4. Circular Wait: Impose a total ordering of all resource types and require that each
process requests resources in an increasing order of enumeration. This prevents the
formation of circular wait chains.

2|Pa ge
Deadlock Detection
Deadlock detection entails the system searching for deadlocks on a regular basis and
resolving them. Usually, techniques that identify cycles in the resource allocation
graph are used for this. A cycle suggests that there is a deadlock if one is found. After
that, the system can take remedial measures like:

 Process Termination: Terminate one or more processes involved in the deadlock to


break the cycle. This can be done by terminating all deadlocked processes or one
process at a time until the deadlock is resolved.
 Resource Pre-emption: Pre-empt resources from some processes and allocate them to
others until the deadlock is broken. This requires careful consideration to ensure that
the system does not enter another deadlock state.

Conclusion
In conclusion, deadlocks pose a serious problem for computer systems because they cause
processes to become permanently stopped while they wait for resources that are shared by
other processes. It is crucial to comprehend the ideas of deadlock avoidance, prevention, and
detection while building reliable systems that can manage resource allocation effectively.

Deadlock avoidance ensures that the system never enters an unsafe state by dynamically
analysing resource requests and allocations. Deadlock prevention proactively eliminates
one or more of the necessary conditions for deadlock, thereby preventing its occurrence.
Deadlock detection involves periodically checking for deadlocks and taking corrective
actions to resolve them.

By putting these tactics into practice, system designers may guarantee efficient and effective
operation, lowering the possibility of deadlocks and preserving system stability. The
advantages and disadvantages of each technique vary, and the choice of approach is
contingent upon the particular needs and limitations of the system under design.

3|Pa ge

You might also like