keywords: C++, Memory Ordering Notes

Documents

Memory ordering

Memory ordering
https://en.wikipedia.org/wiki/Memory_ordering

std::memory_order
https://en.cppreference.com/w/cpp/atomic/memory_order

Memory Ordering at Compile Time
https://preshing.com/20120625/memory-ordering-at-compile-time/

Memory Reordering Caught in the Act
https://preshing.com/20120515/memory-reordering-caught-in-the-act/

volatile

Single producer single consumer command queue
https://codereview.stackexchange.com/a/152338

Memory barrier (Memory fence)

Understanding c++11 memory fences
https://stackoverflow.com/questions/13632344/understanding-c11-memory-fences

Memory barrier
https://en.wikipedia.org/wiki/Memory_barrier

Does the C++ volatile keyword introduce a memory fence?
https://stackoverflow.com/q/26307071/1645289

Does the C++ volatile keyword introduce a memory fence?
It depends on which compiler “the compiler” is. Visual C++ does, since 2005. But the Standard does not require it, so some other compilers do not.

Reference:
https://stackoverflow.com/a/26307223/1645289

Blogs

Memory Reordering

浅谈Memory Reordering
http://dreamrunner.org/blog/2014/06/28/qian-tan-memory-reordering/

volatile (Thread safe queue)

Creating a thread safe producer consumer queue in C++ without using locks
https://blogs.msmvps.com/vandooren/2007/01/05/creating-a-thread-safe-producer-consumer-queue-in-c-without-using-locks/

Single producer single consumer lock-free queue C++ implementation
https://www.programmersought.com/article/4063419461/

Stay away from Volatile in threaded code?
https://sites.google.com/site/kjellhedstrom2/stay-away-from-volatile-in-threaded-code


Efficiency is doing the thing right. Effectiveness is doing the right thing. ― Peter F. Drucker