CppCon 2016: Hans Boehm “Using weakly ordered C++ atomics correctly"

Sign in to queue

Description

Published on Oct 6, 2016
http://CppCon.org

Presentation Slides, PDFs, Source Code and other presenter materials are available at: https://github.com/cppcon/cppcon2016

Most programmers should usually avoid C++ atomics altogether and use mutexes instead. If that's not possible, perhaps because the code must be usable in interrupt handlers, I recommend that you consider limiting yourself to sequentially consistent atomics, which provide a more subtle, but still reasonably unsurprising programming model. This talk will target those who choose to ignore both of those pieces of advice, for either good or bad reasons.
I will start by trying to distinguish the good and bad reasons for using weakly ordered atomics, and then follow with guidelines for using them correctly.
I will discuss why it is often incorrect to think of atomics in terms of fence-based implementations, and about some common errors I've seen, including some really convincing looking, but still incorrect, code. I will also try to go through some of the common idioms for which weakly ordered atomics are actually safe. In my experience, the latter are also reasonably common, but not always easy to distinguish from the subtly erroneous examples.

Hans Boehm
Google
Hans is the WG21 SG1 (Concurrency) Chair, and co-led the design of the C++ memory model and atomic operations. He now mostly works on concurrency-related issues in Android, and occasionally on teaching calculators to calculate correctly. In the past, he mostly focused on garbage collection. He is the original primary author of bdwgc, a conservative garbage collector for C and C++. http://hboehm.info

Videos Filmed & Edited by Bash Films: http://www.BashFilms.com

Day:

3

Embed

Download

Download this episode

The Discussion

Add Your 2 Cents