Deadlock, Livelock and Starvation - Baeldung On Computer Science
Deadlock, Livelock and Starvation - Baeldung On Computer Science
(/cs/) (https://www.baeldung.com/cs/)
by baeldung (https://www.baeldung.com/cs/author/baeldung)
1. Introduction
https://www.baeldung.com/cs/deadlock-livelock-starvation#:~:text=Livelock is a deadlock-like,resource denial to a process. 1/10
1/27/22, 10:45 AM Deadlock, Livelock and Starvation | Baeldung on Computer Science
2. Deadlock
In this section, we’ll first discuss deadlock, its necessary conditions, and
how to prevent it.
The above figure shows the deadlock scenario between process 1 and
process 2. Both processes are holding one resource and waiting for the
other resource held by the other process. This is a deadlock situation as
SPONSORED BY GWI
See More
(https://freestar.com/?
See More
(https://freestar.com/?
No Preemption: To make this condition false, a process needs to make
sure that it automatically releases all currently held resources if the
/freestar.com/?
newly requested resource is not available.
o&utm_source=baeldung.com&utm_content=baeldung_adhesion)
Circular Wait: This condition can be made false by imposing a total
ordering of all resource types and ensure that each process requests
resources in increasing order of enumeration. Thus, if there is a set of
resources , a process requires resource and to complete
a task, it needs to request first and then .
3. Livelock
In this section, we’ll discuss live lock which is similar to deadlock with a
subtle difference.
/freestar.com/?
o&utm_source=baeldung.com&utm_content=baeldung_adhesion)
The above figure shows an example of livelock. Both “process 1” and
“process 2” need a common resource. Each process checks whether the
other process is in an active state. If so, then it hands over the resource
to the other process. However as both, the process is inactive status,
both kept on handing over the resource to each other indefinitely.
Prestige Group
(https://freestarcom/?
A real-world example of livelock occurs when two people make a
telephone call to each other and both find the line is busy. Both
gentlemen decide to hang up and attempt to call after the same time
interval. Thus, in the next retry too, they ended up in the same situation.
This is an example of a live lock as this can go on forever.
4. Starvation
In this section, we’ll discuss starvation which generally occurs as a result
of a deadlock, livelock, or caused by a greedy process.
Never wait for Buyer Payments. Discount your export bills with
(htt //f t /?
5. Conclusion
In this article, we discussed concepts of deadlock, livelock, and
starvation which occur in a multi-processing operating system.
A deadlock is a situation that occurs when processes block each other
with resource acquisition and makes no further progress. Livelock is a
deadlock-like situation in which processes block each other with a
See More
(https://freestar.com/?
CATEGORIES
ALGORITHMS (/CS/CATEGORY/ALGORITHMS)
ARTIFICIAL INTELLIGENCE (/CS/CATEGORY/AI)
CORE CONCEPTS (/CS/CATEGORY/CORE-CONCEPTS)
DATA STRUCTURES (/CS/CATEGORY/DATA-STRUCTURES)
GRAPH THEORY (/CS/CATEGORY/GRAPH-THEORY)
LATEX (/CS/CATEGORY/LATEX)
NETWORKING (/CS/CATEGORY/NETWORKING)
SECURITY (/CS/CATEGORY/SECURITY)
SERIES
DRAWING CHARTS IN LATEX (/CS/CATEGORY/SERIES)
ABOUT
ABOUT BAELDUNG (HTTPS://WWW.BAELDUNG.COM/ABOUT)
THE FULL ARCHIVE (/CS/FULL_ARCHIVE)
WRITE FOR BAELDUNG (/CONTRIBUTION-GUIDELINES)
EDITORS (HTTPS://WWW.BAELDUNG.COM/EDITORS)