Threads in the new ISO C Standard from 2011
Threads in the new ISO C Standard from 2011
Threads in the new ISO C Standard from 2011
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Memory Order for Atomic Operations<br />
The enumerated type memory_order conta<strong>in</strong>s <strong>the</strong> enumerators<br />
memory_order_relaxed<br />
memory_order_consume<br />
memory_order_acquire<br />
memory_order_release<br />
memory_order_acq_rel<br />
memory_order_seq_cst<br />
They are used with <strong>the</strong> functions operat<strong>in</strong>g on atomic objects<br />
described next.<br />
For example:<br />
x = atomic_load_explicit(&a, memory_order_relaxed);<br />
y = atomic_load(&b);<br />
Without _explicit, memory_order_seq_cst is used.<br />
As we will see <strong>in</strong> detail <strong>the</strong> code becomes faster and more confus<strong>in</strong>g<br />
with memory_order_relaxed. Crash<strong>in</strong>g fast is better.<br />
Jonas Skeppstedt (js@cs.lth.se) Lecture 6 2013 9 / 70