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.

Inter-Thread Happens Before<br />

An evaluation A <strong>in</strong>ter-thread happens before an evaluation B if:<br />

A synchronizes with B (mutex unlock/lock), or<br />

A is dependency ordered before B (release/consume), or<br />

for some evaluation X :<br />

A synchronizes with X and X is sequenced before B, or<br />

A is sequenced before X and X synchronizes with B, or<br />

A <strong>in</strong>ter-thread happens before X and X <strong>in</strong>ter-thread happens before B.<br />

An evaluation A happens before an evaluation B if:<br />

A is sequenced before B (<strong>in</strong>tra-thread), or<br />

A is <strong>in</strong>ter-thread happens before B.<br />

C11, Section 5.1.2.4 paragraph 25:<br />

The execution of a program conta<strong>in</strong>s a data race if it conta<strong>in</strong>s two<br />

conflict<strong>in</strong>g actions <strong>in</strong> different threads, at least one of which is not<br />

atomic, and nei<strong>the</strong>r happens before <strong>the</strong> o<strong>the</strong>r. Any such data race<br />

results <strong>in</strong> undef<strong>in</strong>ed behavior.<br />

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

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

Saved successfully!

Ooh no, something went wrong!