Part 3. More concurrency

 

In this part of the book, we’ll look at more advanced concurrency topics: concurrency patterns, deadlocking, atomic variables, and futexes.

We’ll start by reviewing some common patterns used to break down problems into multiple parts that can be executed in parallel, and we’ll see how some patterns are better suited for different types of problems. We’ll also explore patterns such as loop-level parallelism, fork/join, worker pools, and pipelining, and we’ll discuss the properties of each.

Deadlocks can be a bad side effect of a concurrent system. Deadlocks happen when we have two or more threads of execution blocking each other in a circular fashion. We’ll examine some examples of deadlocks, with both memory sharing and message passing, and discuss various options for avoiding and preventing deadlocks in our programs.

In this book, we’ve looked at the implementations of various concurrency tools. Here we’ll look at the most primitive of our concurrent tools: the mutex. We’ll explore how the mutex uses an atomic operation internally, together with an operating system call, to achieve the best results in terms of performance.