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.

Syntax for Declar<strong>in</strong>g Atomic Objects<br />

A <strong>new</strong> type qualifier: _Atomic.<br />

The o<strong>the</strong>r type qualifiers are: const, volatile, restrict.<br />

Examples:<br />

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

<strong>in</strong>t* _Atomic b; // atomic po<strong>in</strong>ter<br />

_Atomic <strong>in</strong>t* c; // po<strong>in</strong>ter to atomic <strong>in</strong>t<br />

_Atomic <strong>in</strong>t* _Atomic c; // atomic po<strong>in</strong>ter to atomic <strong>in</strong>t<br />

_Atomic struct { <strong>in</strong>t d; } e; // atomic struct<br />

In C++ it’s written as atomic a.<br />

For easier port<strong>in</strong>g C allows: _Atomic (type-name)<br />

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

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

Saved successfully!

Ooh no, something went wrong!