Trusted answers to developer questions

What is the starvation problem?

Get the Learn to Code Starter Pack

Break into tech with the logic & computer science skills you’d learn in a bootcamp or university — at a fraction of the cost. Educative's hand-on curriculum is perfect for new learners hoping to launch a career.

When a process is waiting for a resource that is repeatedly given to some other process, it is known as starvation.

Let’s say the operating system uses a very simple implementation of Priority Queue for resource allocation, but a higher priority process keeps a lower priority process from ever getting the resource. This means that the low priority process is starved.

Deadlock

A deadlock is when a process is waiting on a resource that is held by a second process. The second process is in turn waiting for a resource that is held by the first process. In this scenario, neither of the processes are able to move forward.

For example, Process 1 has acquired Resource 1. Now, Process 1 is waiting on Resource 2. Additionally, Resource 2 has been acquired by Process 2; so, Process 2 is waiting for Resource 1. In effect, neither Process 1 nor Process 2 can make any progress. This is called as deadlock.

Starvation

As previously stated, starvation is when a process keeps waiting for a resource that is being given to other processes. This is shown below:

Solution to starvation

A low priority task’s priority is bumped up based on how much time it has been in the queue. This is known as Aging and ensures that even the lowest priority processes are eventually bumped up to the highest priority.

RELATED TAGS

general
Did you find this helpful?