The Wayback Machine - https://web.archive.org/web/20240927084842/https://www.geeksforgeeks.org/difference-between-deadlock-and-starvation-in-os/
Open In App

Difference between Deadlock and Starvation in OS

Last Updated : 06 Sep, 2024
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

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.

Deadlock

There are Four Conditions That May Occur in Deadlock

  1. Mutual Exclusion: It simply states that one process can only access a resource at any point in time. 
  2. Hold and Wait: One or several processes are waiting for other processes, which in turn are holding resources that the processes are waiting for. 
  3. No Preemption: One cannot force the resources to be removed from the process that has it. 
  4. 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: 

  1. Avoid Circular Wait: Adopt a proper hierarchy of resources in order to maintain an order in the resource list. 
  2. Release Resources: Make certain processes return a signal if they cannot go on any further. 
  3. 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 

  1. Priority Scheduling: If there are always higher-priority processes available, then the lower-priority processes may never be allowed to run. 
  2. 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

Deadlock, Starvation, and Livelock
Prerequisite - Deadlock and Starvation  Livelock occurs when two or more processes continually repeat the same interaction in response to changes in the other processes without doing any useful work. These processes are not in the waiting state, and they are running concurrently. This is different from a deadlock because in a deadlock all processes
6 min read
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 necessary for deadlock while deadlock avoidance refer
4 min read
Starvation and Aging in Operating Systems
Starvation occurs when a process in the OS runs out of resources because other processes are using it. This is a problem with resource management while Operating systems employ aging as a scheduling approach to keep them from starving. It is one of the most common scheduling algorithms in batch systems. Each process is assigned a priority. The proc
6 min read
Starvation in DBMS
Starvation or Livelock is the situation when a transaction has to wait for an indefinite period of time to acquire a lock. Reasons for Starvation:If the waiting scheme for locked items is unfair. ( priority queue )Victim selection (the same transaction is selected as a victim repeatedly )Resource leak.Via denial-of-service attack.Starvation can be
5 min read
Relation Between Number of Processes and Number of Resources to Prevent Deadlock
A set of blocked processes where each process is holding some resource and waiting to acquire some other resource held by another process in the set. This situation is called deadlock in the operating system. Deadlock can be prevented if the number of resource instances in a system is significantly larger than the number of processes asking for a r
3 min read
Introduction to TimeStamp and Deadlock Prevention Schemes in DBMS
Deadlock occurs when each transaction T in a schedule of two or more transactions waiting for some item locked by some other transaction T' in the set. Thus, both end up in a deadlock situation, waiting for the other to release the lock on the item. Deadlocks are a common problem and we have introduced the problem while solving the Concurrency Cont
7 min read
Deadlock Prevention And Avoidance
When two or more processes try to access the critical section at the same time and they fail to access simultaneously or stuck while accessing the critical section then this condition is known as Deadlock. Deadlock prevention and avoidance are strategies used in computer systems to ensure that different processes can run smoothly without getting st
6 min read
Deadlock Detection And Recovery
Deadlock Detection and Recovery is the mechanism of detecting and resolving deadlocks in an operating system. In operating systems, deadlock recovery is important to keep everything running smoothly. A deadlock occurs when two or more processes are blocked, waiting for each other to release the resources they need. Detection methods help identify w
6 min read
Operating Systems | Deadlock | Question 1
Suppose n processes, P1, …. Pn share m identical resource units, which can be reserved and released one at a time. The maximum resource requirement of process Pi is Si, where Si > 0. Which one of the following is a sufficient condition for ensuring that deadlock does not occur? (A) A (B) B (C) C (D) D Answer: (C) Explanation: See Question 4 on foll
1 min read
Operating Systems | Deadlock | Question 2
Consider the following snapshot of a system running n processes. Process i is holding Xi instances of a resource R, 1 <= i <= n. currently, all instances of R are occupied. Further, for all i, process i has placed a request for an additional Yi instances while holding the Xi instances it already has. There are exactly two processes p and q su
1 min read
Chandy-Misra-Haas's Distributed Deadlock Detection Algorithm
Chandy-Misra-Haas's distributed deadlock detection algorithm is an edge chasing algorithm to detect deadlock in distributed systems. In edge chasing algorithm, a special message called probe is used in deadlock detection. A probe is a triplet (i, j, k) which denotes that process Pi has initiated the deadlock detection and the message is being sent
4 min read
Deadlock Ignorance in Operating System
In this article we will study in brief about what is Deadlock followed by Deadlock Ignorance in Operating System. What is Deadlock? If each process in the set of processes is waiting for an event that only another process in the set can cause it is actually referred as called Deadlock. In other words, one event which has to happen by one process wi
5 min read
Deadlock System model
Overview :A deadlock occurs when a set of processes is stalled because each process is holding a resource and waiting for another process to acquire another resource. In the diagram below, for example, Process 1 is holding Resource 1 while Process 2 acquires Resource 2, and Process 2 is waiting for Resource 1. System Model : For the purposes of dea
8 min read
Conditions for Deadlock in Operating System
A deadlock is a situation where a set of processes is blocked because each process is holding a resource and waiting for another resource acquired by some other process. In this article, we will discuss what is deadlock and the necessary conditions required for deadlock. What is Deadlock?Deadlock is a situation in computing where two or more proces
8 min read
Deadlock Detection Algorithm in Operating System
In operating systems, managing resources like memory, files, and processors is very important. Sometimes, processes (or programs) get stuck waiting for each other to release resources, leading to a situation called a deadlock. To handle deadlocks, operating systems use special methods called deadlock detection algorithms. These algorithms help iden
7 min read
Recovery from Deadlock in Operating System
In today's world of computer systems and multitasking environments, deadlock is an undesirable situation that can bring operations to a halt. When multiple processes compete for exclusive access to resources and end up in a circular waiting pattern, a deadlock occurs. To maintain the smooth functioning of an operating system, it is crucial to imple
8 min read
Introduction of Deadlock in Operating System
A deadlock is a situation where a set of processes is blocked because each process is holding a resource and waiting for another resource acquired by some other process. In this article, we will discuss deadlock, its necessary conditions, etc. in detail. What is Deadlock?Deadlock is a situation in computing where two or more processes are unable to
11 min read
Deadlock in DBMS
In database management systems (DBMS) a deadlock occurs when two or more transactions are unable to the proceed because each transaction is waiting for the other to the release locks on resources. This situation creates a cycle of the dependencies where no transaction can continue leading to the standstill in the system. The Deadlocks can severely
10 min read
Difference between Difference Engine and Analytical Engine
Introduction: The development of computing technology has a rich history, with many inventions and innovations leading to the creation of the modern computer. Two such machines, the Difference Engine and Analytical Engine, were created by the English mathematician and inventor Charles Babbage in the 19th century. While these machines share some sim
7 min read
Difference between Voltage Drop and Potential Difference
Voltage Drop is defined as the decrease in the electric potential along the path of current that is flowing in an electric circuit. Voltage drop can be assigned at each point in the electric circuit that is proportional to the electrical elevation. The amount of energy delivered per second to any component in the circuit is equal to the voltage dro
4 min read
Difference Between Electric Potential and Potential Difference
The flow of electric charges is known as electricity, and it is responsible for producing electric current. An important word associated with electricity is electric potential. A potential difference is required to create the flow of electrons and hence, produce electricity. Before understanding the difference between electric potential and potenti
7 min read
Difference and Similarities between PHP and C
PHP is a server-side scripting language designed specifically for web development. It can be easily embedded in HTML files and HTML codes can also be written in a PHP file. The thing that differentiates PHP from a client-side language like HTML is, PHP codes are executed on the server whereas HTML codes are directly rendered on the browser. C is a
3 min read
Similarities and Difference between Java and C++
Nowadays Java and C++ programming languages are vastly used in competitive coding. Due to some awesome features, these two programming languages are widely used in industries as well as comepetitive programming . C++ is a widely popular language among coders for its efficiency, high speed, and dynamic memory utilization. Java is widely used in the
6 min read
Difference between Time Tracking and Time and Attendance Software
Time tracking and time and attendance software are tools that help businesses track the time that employees spend on tasks and their attendance records. These tools can help businesses automate their time tracking processes, reduce errors and inaccuracies, and ensure that employees are paid accurately for the time they work. Time tracking software
4 min read
Difference Between Single and Double Quotes in Shell Script and Linux
Single quotes and double quotes are both functional in Linux while working with shell scripts or executing commands directly in the terminal but there is a difference between the way the bash shell interprets them. Single quotes: Enclosing characters in single quotation marks (') holds onto the literal value of each character within the quotes. In
3 min read
Difference Between Monophyletic and vs Paraphyletic and vs Polyphyletic
In phylogeny, a taxon is a collection of organisms. Defining taxa makes it simpler to classify and identify creatures while also helping us to understand how they relate to one another. Based on these traits, taxa are developed. While some taxa are made up of unrelated creatures, others contain related species. Taxa classify descendants and ancesto
7 min read
Difference Between Grin And Smile And Smirk
Difference Between Grin And Smile And Smirk: Emotions are expressed by facial expressions. Facial expressions are considered an as important aspect of non-verbal communication. Facial expressions consist of various different body moments such as moving lips upward or downward, movement of raising the eyebrows, and giving the wide smile while descri
6 min read
Difference Between AND Gate and OR Gate
AND gate and OR gate are basic logic gates. AND gate outputs 1 when all inputs are 1 else output 0. OR gate outputs 1 when at least one input is 1 else output 0. The main difference between AND gate and OR gate is that AND gate represents logical conjunction whereas OR gate represents logical disjunction. In this article we will explore difference
4 min read
Difference Between Store‑and‑Forward Switching and Cut‑Through Switching
Switching is a technique to transmit data between networks using switches that connect multiple LANs. Switches forward data packets based on MAC addresses, efficiently using bandwidth and reducing collisions. The three main types are: Circuit Switching: Dedicated path for the entire connection, used in traditional telephony.Message Switching: Entir
5 min read
Difference between Stop and Wait protocol and Sliding Window protocol
Both the Stop and Wait protocol and the Sliding Window protocol are the techniques to the solution of flow control handling. The main difference between the Stop-and-wait protocol and the Sliding window protocol is that in the Stop-and-Wait Protocol, the sender sends one frame and waits for acknowledgment from the receiver whereas in the sliding wi
5 min read