Difference between Deadlock and Starvation in OS
Last Updated :
28 Dec, 2024
Deadlock is a condition wherein all the processes are holding one resource each and are waiting for another process to release another resource. Starvation is a state that prevents lower-precedence processes from getting the resources. Starvation arises when procedures with critical importance keep on utilizing the resources frequently.
Therefore, as we want to compare these two, we have to get acquainted with both of these terms in a much deeper way. I am excited to know more about operating systems, especially the deep concepts of operating systems. So, let’s get started.
What is Deadlock?
Deadlock occurs when each process holds a resource and waits for other resources held by any other process. The necessary conditions for deadlock to occur are Mutual Exclusion, Hold and Wait, No Preemption, and Circular Wait. In this, no process holding one resource and waiting for another gets executed. For example, in the below diagram, Process 1 is holding Resource 1 and waiting for Resource 2 which is acquired by Process 2, and Process 2 is waiting for Resource 1. Hence both process 1 and process 2 are in deadlock.
In other words, “Deadlock is a situation in which two or more processes require resources to complete their execution, but those resources are held by another process. Due to which the execution of the process is not completed.”
For example, suppose there are two friends and both want to play computer games, due to which they fight. One has a remote control, and the other has a CD of games.
Due to this, neither of the two friends can play, but neither of them is ready to cooperate. This situation is called deadlock.

There are Four Conditions That May Occur in Deadlock
- Mutual Exclusion: It simply states that one process can only access a resource at any point in time.
- Hold and Wait: One or several processes are waiting for other processes, which in turn are holding resources that the processes are waiting for.
- No Preemption: One cannot force the resources to be removed from the process that has it.
- Circular Wait: A cyclic chain of processes is present, and every process is holding at least one resource and waiting for some process that is holding the resource that is required by the immediate successive process.
Prevention of Deadlock
To avoid deadlock, it is necessary to remove at least one of the prerequisites that may lead to that. For instance:
- Avoid Circular Wait: Adopt a proper hierarchy of resources in order to maintain an order in the resource list.
- Release Resources: Make certain processes return a signal if they cannot go on any further.
- Preemption: Enable the deprivation of resources by the system z under specific circumstances.
Advantages of Deadlock
- Detection and Prevention Research : Helps to create the detection and prevention algorithms, which in turn contribute towards the overall evolution of computer science, especially in the management of resources.
- Resource Allocation Efficiency Studies: Assists researchers in utilization, the allocation, of resources in operation systems and thus encourages innovative designs.
- Ensures Process Fairness: When solved effectively, it maintains that no process takes more than its fair share of the resources, hence achieving overall system fairness.
- Avoidance Strategy Improvements: Kindled innovation in the formulation of ways of minimizing deadlocks to inform on the best resource allocation approaches in enhancing the design of systems.
Disadvantages of Deadlock
- System Freeze: The most serious disadvantage is that the system may be locked and no process can go on as critical sections are mutually exclusive.
- Resource Wastage: Those resources trapped in the deadlocked processes cannot be utilized by the other process, and this leads to low efficiency of the system.
- System Instability: Deadlocks can result in the unavailability of necessary services that can result in the crashing of the system.
- High Complexity in Detection: To identify deadlocks is a computationally intensive process, particularly when there are numerous processes and resources in the system.
What is Starvation?
Starvation is the problem that occurs when high priority processes keep executing and low priority processes get blocked for indefinite time. In heavily loaded computer system, a steady stream of higher-priority processes can prevent a low-priority process from ever getting the CPU. In starvation resources are continuously utilized by high priority processes. Problem of starvation can be resolved using Aging. In Aging priority of long waiting processes is gradually increased.
Causes of Starvation
- Priority Scheduling: If there are always higher-priority processes available, then the lower-priority processes may never be allowed to run.
- Resource Utilization: We see that resources are always used by more significant priority processes and leave a lesser priority process starved.
Prevention of Starvation
Starvation can be cured using a technique that is regarded as aging. In aging, priority of process increases with time and thus guarantees that poor processes will equally run in the system.
Advantages of Starvation
- Prioritizes Critical Tasks: The high-priority tasks can run at once, thereby improving on the, for instance, real-time systems where some tasks are very limited in time.
- Efficiency for High-Priority Processes: Helps guarantee that effective/ineffective utilization of resources by such critical/time-sensitive processes enhances performance in many systems.
- Optimizes Resource Usage for Priority Processes: This means that resources are constantly reallocated to where they are needed most, or in other words, resources are well aligned with high-priority jobs.
- Simplicity in Scheduling: Stagnation is a common result of simple priority scheduling, which is comparatively less tricky to balance from the other algorithms.
Disadvantages of Starvation
- Process Delays: Some of the less important processes may never run at all or run very late indeed, which can translate into very long wait times or worse, system failure.
- Unfair Resource Distribution: Resource allocation becomes unfair. I/O-bound processes starve and may not run their turn efficiently.
- System Inefficiency : In the long run, the system efficiency may be an issue, especially because unnecessary and less important tasks may accumulate time and compress the system.
- Potential for Resource Starvation : Essential yet less critical processes could never execute, which potentially results in poor service provision and the health of the system.
Difference Between Deadlock and Starvation
| Deadlock |
Starvation |
| All processes keep waiting for each other to complete and none get executed |
High priority processes keep executing and low priority processes are blocked |
| Resources are blocked by the processes |
Resources are continuously utilized by high priority processes |
| Necessary conditions Mutual Exclusion, Hold and Wait, No preemption, Circular Wait |
Priorities are assigned to the processes |
| Also known as Circular wait |
Also known as lived lock |
| It can be prevented by avoiding the necessary conditions for deadlock |
It can be prevented by Aging |
Conclusion
The two most important problems found in operating system resources are lock-hold and starvation. While deadlock arises because processes wait for one another, causing a cycle, starvation arises when processes with low priority are continually delayed by high-priority processes that continuously use the resources. All the said problems can be minimized through the correct strategies, such as not allowing circular waits and aging, which help distribute the resources appropriately.
Difference Between Deadlock and Starvation in OS -FAQs
Can deadlock and starvation occur simultaneously?
In fact, deadlock and starvation are two different issues. Deadlock is a state where all processes become blocked and the processes are waiting for their resources to be released, whereas in a starvation situation, a process is never given a chance to execute because it is always preempted by a higher-priority process.
What is the primary cause of starvation?
Starvation mainly results from the priority scheduling algorithm, in which the system’s higher-priority processes always preempt the lower-priority ones.
How does aging resolve starvation?
Aging serves to increase the priority of a waiting process over time, thereby guaranteeing that low-priority processes will be executed.
Can a system be deadlock-free and still experience starvation?
Nevertheless, it is crucial for understanding that starvation is still possible in the systems that have been devised in order not to allow the deadlock to take place if the priority scheduling is not efficiently handled.
Similar Reads
Difference between Tokenization and Masking
Tokenization and Masking are two different data security methods that are used for data security but they work differently and for different purposes. The distinction between these two methods is important in choosing a proper approach to data protection in different applications of business. Tokeni
6 min read
Difference between SVG file and PNG
When it comes to choosing the right image format for your projects, understanding the difference between SVG and PNG files can make a big impact on the quality and performance of your designs. SVG (Scalable Vector Graphics) and PNG (Portable Network Graphics) are two popular image formats used in we
5 min read
Difference between Beam Penetration and Shadow Mask
Prerequisite - Refresh type output devices 1. Beam Penetration Method : Beam Penetration Method is quite similar to the normal CRT and it uses only one electron gun. In this, different colors of multi-layered are coated on inner surface of screen, normally the two layers of phosphorus i.e., red and
2 min read
Difference between JPEG and PNG
JPEG and PNG are two different types of format used to store the images. JPEG: It stands for Joint Photographic Experts Group. Extensions used to store image in this format are .jpg and .jpeg. It uses lossy compression algorithm, it means some of the image data is lost but image size is reduced. PNG
4 min read
Difference between Steganography and Cryptography
Steganography and cryptography are critical components of network security. Network security has emerged as an essential part of today's communication infrastructure. There was an urgent need for network security to protect confidentiality and data integrity. It protects the user against unauthorize
3 min read
Difference Between JPEG and MPEG
Pre-requisites: JPEG, MPFG JPEG stands for Joint Photographic Experts Group. .jpg and .jpeg extensions are used to store images in this format. It uses a lossy compression algorithm, which means some of the image data is lost. Advantages of JPEG: Small file size: JPEG images can be compressed to sma
3 min read
JPG or PNG - Which Image Format Offers Better Quality?
In this digital world, People store their images/photos on mobile/computer/drives, etc. But the question arises of which format to choose, there are two image formats available. Which one is better? These questions come to your mind and to answer we are writing this article. This article includes th
5 min read
Adobe RGB vs sRGB
Images have become an inseparable part of our life, but one question always comes to mind, what these images are made of, so the simple answer is pixels which are actually the colour dots. Hence an image consists of a large number of color dots and because of this, it is obvious that different image
3 min read
Canva vs GIMP Comparison
Images are an extremely powerful way to present information either for showing a new product or service or to explain any typical concept. Around 3.2 billion images are uploaded on the internet on a daily basis which makes it a huge opportunity for graphic companies to produce image editing, creatio
3 min read
Background Subtraction in an Image using Concept of Running Average
Background subtraction is a technique for separating out foreground elements from the background and is done by generating a foreground mask. This technique is used for detecting dynamically moving objects from static cameras. Background subtraction technique is important for object tracking. There
4 min read
Image Edge Detection Operators in Digital Image Processing
Edges are significant local changes of intensity in a digital image. An edge can be defined as a set of connected pixels that forms a boundary between two disjoint regions. There are three types of edges: Horizontal edgesVertical edgesDiagonal edges Edge Detection is a method of segmenting an image
4 min read
Text extraction from image using LSB based steganography
Prerequisite: LSB based Image steganography using MATLABIn LSB based Image steganography using MATLAB, we saw how to hide text inside an image. In this article, we are going to see given the stego image or the pixel values and the length of the text embedded as input, how to extract the text from it
3 min read
Gradient | Morphological Transformations in OpenCV in C++
In this article, a Morphological Operator called Gradient is discussed. The gradient is defined as the difference between the Dilation and Erosion of an image. Every pixel inside the Gradient image represents the contrast intensity in the neighborhood of a pixel. It is used for image segmentation an
2 min read
Early Evidence of Steganography
Steganography can be referred as an art of invisible communication. It hides the very presence of communication without leaving any apparent evidence. In other words, steganography is a technique to hide secret information in such a way that an outsider cannot even sense the presence of the embedded
4 min read
Image Processing in MATLAB | Fundamental Operations
1. Reading Images Images are read into the MATLAB Environment using imread() function which takes filename with applicable extension as the argument For Example: >> I=imread('nature.jpg'); This will read JPEG image 'nature' into the image array. Note: The semicolon(;) at the end of command lin
3 min read
Digital Watermarking and its Types
Digital Watermarking is use of a kind of marker covertly embedded in a digital media such as audio, video or image which enables us to know the source or owner of the copyright. This technique is used for tracing copyright infringement in social media and knowing the genuineness of the notes in the
3 min read
Noise Models in Digital Image Processing
The principal source of noise in digital images arises during image acquisition and transmission. The performance of imaging sensors is affected by a variety of environmental and mechanical factors of the instrument, resulting in the addition of undesirable noise in the image. Images are also corrup
3 min read
Matlab program to rotate an image 180 degrees clockwise without using function
An image is defined as two-dimensional function, f(x, y), where x and y are spatial (plane) coordinates, and the amplitude of f at any pair of coordinates(x, y) is called the Intensity or the Gray level of the image at that point. When x, y and the intensity values of f are all finite, discrete quan
2 min read
Digital Image Processing Algorithms using MATLAB
Like it is said, "One picture is worth more than ten thousand words "A digital image is composed of thousands and thousands of pixels. An image could also be defined as a two-dimensional function, f(x, y), where x and y are spatial (plane) coordinates and therefore the amplitude of f at any pair of
8 min read