What is the difference between Deadlock and Starvation?
• In deadlock, the two threads or processes will wait for each other and both do not proceed forward.
• In starvation, when two or more threads or processes wait for the same resource, one will roll back and let the others use the resource first and next the starving thread or process will try again . Therefore, all threads or processes will anyhow proceed forward.
• Rolling Back:
• In a deadlock, both high priority threads/processes, as well as low priority threads/processes, will wait for each other infinitely. It never ends.
• But, in a starvation, low priority ones will wait or roll back but high priority ones will proceed.
• Waiting or Lock:
• A deadlock is a circular waiting.
• A starvation is a kind of a livelock and sometimes helps to get out from a deadlock.
• Deadlock and Starvation:
• A deadlock causes starvation, but starvation does not cause a deadlock.
• A deadlock will occur due to mutual exclusion, hold and wait, no preemption or circular waiting.
• Starvation occurs due to scarcity of resources, uncontrolled management of resources, and process priorities.
Deadlock vs. Starvation
Deadlock and starvations are some of the problems that occur due to data races and race conditions that occur during programming as well as implementing hardware. In a deadlock, two threads will infinitely wait for each other without executing while, in a starvation, one thread will roll back and let the other thread to use the resources. A deadlock will cause starvation whereas starvation will help a thread to get out from a deadlock.
- answered 3 years ago
- Sunny Solu