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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Us<strong>in</strong>g <strong>the</strong> Weak Compare and Exchange Functions<br />

_Atomic <strong>in</strong>t a;<br />

<strong>in</strong>t exp;<br />

<strong>in</strong>t value;<br />

exp = atomic_load(&a);<br />

do<br />

value = f(exp);<br />

while (!atomic_compare_exchange_weak(&a, &exp, value));<br />

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

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

Saved successfully!

Ooh no, something went wrong!