06.08.2013 Views

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

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Atomic Exchange Macros<br />

These and <strong>the</strong> follow<strong>in</strong>g atomic operations are called functions <strong>in</strong> <strong>the</strong><br />

standard but are macros.<br />

A refers to an atomic type, e.g. _Atomic <strong>in</strong>t.<br />

C refers to <strong>the</strong> correspond<strong>in</strong>g non-atomic type, i.e. <strong>in</strong>t.<br />

The atomic exchange function writes a <strong>new</strong> value and returns <strong>the</strong> old<br />

value po<strong>in</strong>ted to by ptr.<br />

C atomic_exchange_explicit(volatile A* ptr, C value, memory_order order);<br />

C atomic_exchange(volatile A* ptr, C value);<br />

Jonas Skeppstedt (js@cs.lth.se) Lecture 6 2013 12 / 70

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!