Concurrent System Programming with C++
In this chapter, we will look at what concurrency means and how it is different from parallelism. We will go through the fundamentals and the theory behind processes and threads. We will look at the changes in the C++ memory model, which enforce native concurrency support in the language. We will also familiarize ourselves with what a race condition is, how it can lead to a data race, and how to prevent data races. Next, we will get acquainted with the C++20 std::jthread
primitive, which enables multithreading support. We will learn about the specifics of the std::jthread
class and how we can stop already running std::jthread
instances by using the std::stop_source
primitive. Finally, we will learn how to synchronize the execution of concurrent code and how to report calculation results from executed tasks. We will learn how to use C++ synchronization primitives such as barriers and latches to synchronize the execution of concurrent tasks, and...