Difference between Deadlock and Starvation in OS
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. Practice GATE exam well before the actual exam with the subject-wise and overall quizzes available in GATE Test Series Course.
Learn all GATE CS concepts with Free Live Classes on our youtube channel.