Starvation

Learn about the starvation concept in general.

Overview of starvation

The concepts of concurrency and race condition work fine only when the whole block of code executes without preemption. But, why is preempting necessary? Can’t the process execute completely and then schedule another process?

Let’s consider a case in which we have five processes. Each process has a different priority, and a preemptive scheduling strategy is being used to schedule the allocation of the CPU to these processes. The process with the highest priority will execute first.

But what happens if the process with the highest priority keeps executing? The processes with the lower priorities will never get the CPU to complete their tasks. This situation is known as starvation. A starvation condition occurs when high-priority tasks continue to execute one after the other, while low-priority tasks starve for a chance to execute.

Get hands-on with 1400+ tech skills courses.