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|
- Deadlock, Starvation, and Livelock
- Starvation in DBMS
- Starvation and Aging in Operating Systems
- Deadlock in DBMS
- Deadlock Detection And Recovery
- Deadlock Prevention And Avoidance
- Operating Systems | Deadlock | Question 1
- Introduction of Deadlock in Operating System
- Operating Systems | Deadlock | Question 2
- Deadlock detection in Distributed systems
- Deadlock Detection in Distributed Systems
- Recovery from Deadlock in Operating System
- Hierarchical Deadlock Detection in Distributed System
- Deadlock Detection Algorithm in Operating System
- Program for Deadlock free condition 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 firstname.lastname@example.org. 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.