![]() |
VOOZH | about |
Deadlock and starvation are two different process-scheduling problems. In a deadlock, processes wait forever because each is holding a resource the other needs. In starvation, some processes wait indefinitely because higher-priority processes monopolise resources.
Deadlock is a condition in an operating system where two or more processes are permanently blocked because each process is waiting for a resource that is held by another process, forming a circular waiting chain, and none of them can proceed.
The 4 conditions for Deadlock:
Example:
Two cars on a narrow bridge:
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. 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.
The 4 common causes:
Example:
CPU Scheduling in a Server
| 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 | Poor implementation of scheduling causes starvation like purely based on priority or random selection. |
| 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 |