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.
Similar Reads
Difference between Deadlock Prevention and Deadlock Avoidance Deadlock is a condition where a set of processes becomes stuck and waits infinitely for the resources which are hold by other processes. To handle these types of problems, we use two strategies - Deadlock Prevention and Deadlock Avoidance.Deadlock Prevention means blocking one of the conditions nece
4 min read
Difference Between Mutex and Monitor in OS Pre-requisites: Monitors in Process Synchronization In the field of Computer Science and OS, Mutex, and Monitor are most of the important fundamental mechanisms which are synchronization used for managing the concurrent access of different shared resources by a number of threads and processes. The m
4 min read
Deadlock, Starvation, and Livelock Deadlock, starvation, and livelock are problems that can occur in computer systems when multiple processes compete for resources. Deadlock happens when processes get stuck waiting for each other indefinitely, so none can proceed. Starvation occurs when a process is repeatedly denied access to resour
7 min read
Difference between Process and Thread Process and threads are the basic components in OS. Process is a program under execution whereas a thread is part of process. Threads allows a program to perform multiple tasks simultaneously, like downloading a file while you browse a website or running animations while processing user input. A pro
7 min read
Difference between Operating System and Kernel In the world of computing, two terms that are frequently mentioned are Operating System (OS) and Kernel. In this article, we will explore the key differences between the OS and the Kernel, their functions, and how they work together to manage hardware and software.What is an Operating System?An Oper
3 min read