Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

general
community creator

What is the starvation problem?

Anjana Shankar

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

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
community creator

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring