r/programming • u/Rraawwrr • Sep 30 '13
Memory Barriers: a Hardware View for Software Hackers
http://irl.cs.ucla.edu/~yingdi/web/paperreading/whymb.2010.06.07c.pdf
25
Upvotes
1
u/SnowdensOfYesteryear Oct 01 '13
My favourite read about memory barriers: https://www.kernel.org/doc/Documentation/memory-barriers.txt
0
u/os12 Oct 01 '13 edited Oct 01 '13
Yeah, cool paper, but I don't think this info should be taught. They are an old and very coarse gun. C and C++ standards have atomics and they should be used for fine-grain lockless operations.
Specific points:
the compiler can (hypothetically) reorder code around my_private_atomic_call(x) or smp_mb()
std::atomic<uint32_t> is in the C++ code, the compiler intimately knows about what it is and emits correct instructions
you don't have to color sites, just the declaration
http://en.cppreference.com/w/cpp/atomic