Concurrent Thinking in C++

C++

One of the most difficult issues around designing software with multiple threads of execution is synchronizing data.

Whether you use actors, active objects, futures and continuations or mutable shared state, every non-trivial system with multiple threads needs to transfer data between them. This means thinking about which data needs to be processed by which thread, and ensuring that the right data gets to the right threads in the right order. It also means thinking about API design to avoid race conditions.

This course is aimed at experienced C++ programmers that would like to improve their skills with designing and implementing multithreaded and concurrent code. In this workshop you will encounter a series of scenarios involving multithreaded code, and be guided through
identifying the problem areas and the ways of handling them.

You will learn techniques for thinking about the scenarios to ease the analysis, as well as details of the tools we have available in C++ to mitigate the problems. You will also learn how to use the C++ standard library to help enforce the requirements of each scenario in code.

In addition to lectures, there will be exercises that focus on particular aspects of the design and implementation of multithreaded and concurrent code.

Topics covered in this course:

* The C++ memory model and happens-before

We will look at the ordering guarantees provided by various constructs, and how we can use them to provide synchronization between threads.

* Race conditions and data races

We will look at the difference between a generic race condition and a data race, identifying race conditions, and avoiding them.

* Mutexes and condition variables

Using mutexes to protect data, and avoiding the common pitfalls with condition variable usage.

* Futures and promises

Using futures to synchronize actions, and pass data between threads.

* Atomic operations and lock-free code

Lock-free code isn't just about avoiding mutexes. We will look at correctly synchronizing concurrent actions with atomic operations.

* Designing APIs for concurrent usage

There's more to supporting concurrent usage of an API than merely wrapping the body of each function in a lock. We will look at race conditions inherent in some API designs, and how to avoid them in our own code.

Prerequisites

Students will require a laptop with one of the following compilers to handle the example code:

Microsoft Visual Studio 2015 or later.
gcc 4.9 or later
clang 3.4 or later with libc++ 3.5 or later

Students are expected to have a good knowledge of C++, but no prior knowledge of concurrency or multithreading is assumed.

Tid

09:00 - 17:00