9 Solving Concurrency Problems: Deadlock & starvation
In this chapter
- You learn how to identify and solve common concurrency problems (deadlock, livelock, starvation)
- You learn popular concurrency design patterns: producer-consumer pattern and readers-writers pattern
In the previous chapter, we explored the challenges that arise in concurrent programming, such as race conditions, and the synchronization primitives used to address them. In this chapter, we will now focus on another set of common concurrency problems: deadlock, livelock, and starvation.
These issues can lead to extremely serious consequences, given that concurrency is used in all sorts of technology that we quite literally entrust out lives to. Two Boeing 737 Max airplanes crashed in 2018 and 2019 due to a software error caused by a concurrency problem. The airplanes' Maneuvering Characteristics Augmentation System (MCAS) was designed to prevent the airplane from stalling, but a race condition caused it to malfunction, leading to several fatal crashes that killed a total of 347 people. A decade earlier, Toyota vehicles experienced sudden, unintended acceleration issues in 2009 and 2010. The issue was linked to a software error that caused concurrency problem in the electronic throttle control system. The error caused the throttle to open unexpectedly, leading to several accidents and fatalities.