~/talk

Using weakly ordered C++ atomics correctly

Talkat CppCon 2016 · 2016-09-18..09-23· [concurrency, compilers-and-language-design]
links:none on file
slides:none on file

Most code uses mutexes; atomics are for interrupt handlers or high-performance hotspots, and sequentially consistent atomics give a simpler model at the cost of fence overhead (tens of cycles, cheaper on x86, worse on ARMv7). The useful relaxed options are memory_order_relaxed for per-word counters/harmless diagnostics and acquire/release for publish/subscribe and double-checked initialization. Pitfalls: store→load reordering, compiler-moving loads into critical sections, dependence-based ordering myths, and subtle reference-count and RCU ordering bugs. Use library implementations whenever possible.

AI-written summary · about

  1. 0:00Introduction
  2. 0:21Why atomics
  3. 3:26Before C11
  4. 5:07C11 atomics
  5. 7:46Implementation guarantees
  6. 10:09Simple examples
  7. 12:42Another example
  8. 14:15Costs
  9. 16:25Performance gap
  10. 18:32Memory order relaxation
  11. 21:07Warnings
  12. 25:28Atomicity
  13. 26:48Ordering constraints
  14. 27:14Limitations
  15. 29:02Critical Section
  16. 31:34Dependencies
  17. 34:28General use
  18. 35:36Disclaimer
  19. 35:47Single location data structures
  20. 38:44Double check locking
  21. 41:19Quiet release
  22. 43:30Simple locks
  23. 45:14Reference counting
  24. 49:08Explicit fence
  25. 52:30Only the reader
  26. 54:40Conclusions
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.