CppCon 2017: Fedor Pikus “C++ atomics, from basic to advanced. What do they really do?”
CppCon3 HN recommenders · recommended in 3 months, 2017–2025
talk · advanced · evergreen · 2017–2025 on HN
Fedor Pikus's CppCon 2017 talk on C++ atomics, looking at what they let the programmer express and what the hardware actually does. It covers memory ordering and lock-free programming from basic to advanced.
HN recommends it as an enlightening explanation of atomics, caches and memory ordering from a strong presenter.
Up next
3 mo on HNInside Africa's Food Forest Mega-Project
Andrew Millison
3 HN recommender · 2025–2026
4 mo on HNDe-fragmenting C++: Making Exceptions and RTTI More Affordable and Usable - Herb Sutter CppCon 2019
CppCon
3 HN recommender · 2020–2025
3 mo on HNCppCon 2017: Chandler Carruth “Going Nowhere Faster”
CppCon
2 HN recommender · 2017–2026
2 mo on HNAmazon Sells Fake Electrical Fuses
Louis Rossmann
2 HN recommender · 2024–2026
3 mo on HNJared Mauch - Getting Fiber To My Town (NLNOG Live! September 2020)
NLNOG
3 HN recommender · 2020–2025
9 mo on HNThe essence of calculus
3Blue1Brown
10 HN recommender · 2017–2025
10 mo on HNCppCon 2016: Jason Turner “Rich Code for Tiny Computers: A Simple Commodore 64 Game in C++17”
CppCon
13 HN recommender · 2016–2024
4 mo on HNC++ Exceptions for Smaller Firmware - Khalil Estell - CppCon 2024
CppCon
5 HN recommender · 2025–2026
11 mo on HNCppCon 2015: Andrei Alexandrescu “std::allocator...”
CppCon
7 HN recommender · 2017–2025
12 mo on HNLexical Scanning in Go - Rob Pike
GoogleFOSSSydney
13 HN recommender · 2012–2025
10 mo on HNCppCon 2017: Matt Kulukundis “Designing a Fast, Efficient, Cache-friendly Hash Table, Step by Step”
CppCon
9 HN recommender · 2018–2026
9 mo on HNRustConf 2018 - Closing Keynote - Using Rust For Game Development by Catherine West
Rust Programming Language
9 HN recommender · 2018–2023
3 comments from Hacker News
No, from what I understand, you can't even do it in software anyway due to how the caches work between cores inside the CPU. Watching this was enlightening to say the least (and the presenter is very good): ▶ this video
tl;dr: In a multi-threaded context, memory reads and writes can be reordered by hardware. It gets more complicated with shared cache. Imagine that you have core 1 writing to some address at (nearly) the same time that core 2 reads from that. Does core 2 read the old or the new? Especially if they don't share the same cache -- core 1 might "write" to a given address, but it only gets written to core 1's cache and then "scheduled" to be written out to main memory. Meanwhile, later core 2 tries to read that address, it's not in its cache, so it pulls from main memory before core 1's cache has flushed. As far as core 2 is concerned, the write happened after it read from the address even though physically the write finished in core 1 before core 2's read instruction might have even started. A memory barrier tells the hardware to ensure that reads-before is also "happens-before" (or after) a given writen to the same address. It's often (but not always) a cache and memory synchronization across cores. I found Fedora Pikus's cppcon 2017 presentation [1] to be informative, and Michael Wong's 2015 presentation [0] filled in some of the gaps. C++, being a generic language for many hardware implementations, provides a lot more detailed concepts for memory ordering [2], which is important for hardwares that have more granularity in barrier types that what most people are used to with x86-derived memory models. [0]: link [1]: ▶ this video [2]: link
Fedor Pikus has given a number of great talks on the subject at cppcon over the years some links, in no particular order: CppCon 2017: Fedor Pikus “C++ atomics, from basic to advanced. What do they really do? ▶ this video CppCon 2016: Fedor Pikus “The speed of concurrency (is lock-free faster?)" link CppCon 2015: Fedor Pikus PART 1 “Live Lock-Free or Deadlock (Practical Lock-free Programming)" link CppCon 2015: Fedor Pikus PART 2 “Live Lock-Free or Deadlock (Practical Lock-free Programming)” link CppCon 2017: Fedor Pikus “Read, Copy, Update, then what? RCU for non-kernel programmers” link Tony Van Eerd has also given some talks on lock free queues, I'll leave it as an exercise to the reader to search youtube :)