
Ask HN: How to learn advanced C++ (atomics, memory ordering, etc.) - atmcs
I want to learn the details of lock free programming, atomics, memory ordering, etc. I&#x27;ve been writing concurrent code in C++ for a long time, but not in an environment where I had to think about the memory model.<p>The problem is I haven&#x27;t found much structured content on this. Is there a good book or class syllabus dedicated to this subject?<p>At this point I&#x27;m just piecing together CppCon talks on youtube and blog posts.
======
ecehokie
Hello, Virginia Tech offers an online graduate course called "ECE/CS 5510
Multiprocessor Programming". It specifically focuses on addressing your exact
question within this course and aims to help you understand the multithreaded
programming concepts from the hardware level up to the software level.

I am just starting this course, but the first lecture looked promising and VT
hasn't disappointed me with its ECE courses focused on programming yet.

Here's the book we will be using for the course:
[https://www.elsevier.com/books/the-art-of-multiprocessor-
pro...](https://www.elsevier.com/books/the-art-of-multiprocessor-programming-
revised-reprint/herlihy/978-0-12-397337-5)

~~~
atmcs
Interesting, but looks like this book has examples in Java.

Probably the concepts carry over, but I'd prefer something more directly
applicable to C++.

~~~
arunc
I usually refer to LLVM documentation. You can look at this [1] to begin with.

For sample code, etc, I would recommend to read D's atomic primitive
implementations [2] instead of C++. C++ standard library is an unreadable
monster. Fundamentally C++ atomic types are a flaw as std::atomic<int> is a
type by itself, whereas in reality the operations has to be atomic. Also you
can't get the value type for the type underneath the std::atomic template.

Whereas in D, the operations are atomic and you can operate them on the
primitive types. You can see numerous examples in D's standard library
implementation (which is readable than C++'s) [3][4]

[1] [https://llvm.org/docs/Atomics.html](https://llvm.org/docs/Atomics.html)

[2]
[https://github.com/dlang/druntime/blob/master/src/core/atomi...](https://github.com/dlang/druntime/blob/master/src/core/atomic.d)

[3]
[https://github.com/dlang/phobos/blob/master/std/concurrency....](https://github.com/dlang/phobos/blob/master/std/concurrency.d)

[4]
[https://github.com/dlang/phobos/blob/master/std/parallelism....](https://github.com/dlang/phobos/blob/master/std/parallelism.d)

