Deadlock occurs when each process holds a resource and wait for other resource held by any other process. 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 get 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.
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.
Difference between Deadlock and Starvation:
|1.||All processes keep waiting for each other to complete and none get executed||High priority processes keep executing and low priority processes are blocked|
|2.||Resources are blocked by the processes||Resources are continuously utilized by high priority processes|
|3.||Necessary conditions Mutual Exclusion, Hold and Wait, No preemption, Circular Wait||Priorities are assigned to the processes|
|4.||Also known as Circular wait||Also know as lived lock|
|5.||It can be prevented by avoiding the necessary conditions for deadlock||It can be prevented by Aging|
Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.
- Deadlock, Starvation, and Livelock
- Difference between Deadlock Prevention and Deadlock Avoidance
- Starvation and Aging in Operating Systems
- Starvation in DBMS
- Deadlock Prevention And Avoidance
- Deadlock Detection And Recovery
- Introduction to TimeStamp and Deadlock Prevention Schemes in DBMS
- Introduction of Deadlock in Operating System
- Operating Systems | Deadlock | Question 1
- Operating Systems | Deadlock | Question 2
- Deadlock in DBMS
- Deadlock Detection Algorithm in Operating System
- Deadlock detection in Distributed systems
- Deadlock Detection in Distributed Systems
- Program for Deadlock free condition in Operating System
- Recovery from Deadlock in Operating System
- Hierarchical Deadlock Detection in Distributed System
- Chandy-Misra-Haas's Distributed Deadlock Detection Algorithm
- Conditions for Deadlock in Operating System
- Deadlock Ignorance in Operating System
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.