Starvation
Explore the concept of starvation in Go concurrency, where high-priority processes dominate CPU access, causing low-priority processes to wait indefinitely. Understand causes like preemptive scheduling and resource allocation, and see practical examples illustrating how greedy goroutines can prevent others from progressing.
We'll cover the following...
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 ...