Skip to content
0:00 / 0:00

#lock-free#std::atomic#memorymodel

Lock-free programming with modern C++ - Timur Doumler [ACCU 2017]

ACCU Conference

20K subscribers • 32 videos on Hallway • Conference channel

YouTube
  • One of the most-watched uploads on ACCU Conference, a conference or university channel Hallway lists. Nobody has recommended it in the communities yet, so it ranks below community picks.
  • Presented by Timur Doumler

Advanced. Deep dive for people who know the field.

20K views9 years ago

Systems programmingConcurrency and parallelismC++Performance and optimization

Timur Doumler provides an introduction to lock-free programming using standard C++ atomics and memory models.

Lock-free programming is an important technique for writing thread-safe code for low-latency and real-time applications. It is also often regarded as challenging and notoriously hard to get right. But it doesn’t always have to be that way! This talk gives an accessible but comprehensive introduction to the subject. A lot of material has been published on lock-free programming already. However, the modern C++ standard has significantly improved the situation by introducing an inherently thread-safe generic type – std::atomic – and a well-defined memory model for multithreaded code. It is therefore worth approaching the topic of lock-free programming from the perspective of modern standard C++. In fact, all code examples in this talk will be standard-conforming, portable C++11/14, and we won’t discuss platform-specific solutions. The talk will start by motivating lock-free programming and its use cases. I will then clarify the meaning of terms like atomic, lock-free, and wait-free. Diving into some actual code, we will discuss the usage of std::atomic, its member functions, its template specialisations, compare-exchange operations, and common pitfalls. In the main part of the talk, I will then show various common use-cases of lock-free programming. We will discuss useful and generic ways to safely share and move data across threads without locks and critical sections. We will also work through the implementation of a lock-free data structure: the lock-free queue (also known as fifo or ring buffer). This will serve as an example of how lock-free structures work, when they’re useful, and what to watch out for.

Why it's here

A top upload from a listed channel

ACCU Conference is on Hallway's list of conference and university channels, and this upload is one of its most-watched talks or lectures. Nobody has recommended it in the communities yet, so it ranks below community picks.