From the course: Python Parallel and Concurrent Programming Part 1

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Starvation

Starvation - Python Tutorial

From the course: Python Parallel and Concurrent Programming Part 1

Start my 1-month free trial

Starvation

- It would be nice if Olivia and I took turns acquiring and releasing the pair of chopsticks so we could take an equal amount of sushi from the shared plate, but that's not guaranteed to happen. The operating system decides when each of our threads gets scheduled to execute and depending on the timing of that, it can lead to problems. If Olivia puts down the chopsticks to release her lock on the critical section, but my thread doesn't get a chance to acquire them before she takes them again then I'll be stuck waiting again until she takes another piece. If that happens occasionally, it's probably not a big deal, but if it happens regularly. - Too slow. - Then my thread's going to starve. Starvation occurs when a thread is unable to gain access to a necessary resource and is therefore unable to make progress. If another greedy thread is frequently holding a lock on the shared resource, then the starved thread won't…

Contents