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.

Weak Compare and Exchange Functions<br />

The weak compare and exchange functions may fail spuriously, which<br />

means <strong>the</strong>y fail to perform <strong>the</strong> compare and exchange and ”give up”.<br />

If so, <strong>the</strong> return value is guaranteed to be false, and <strong>the</strong> current value<br />

is not copied to what ptr po<strong>in</strong>ts.<br />

The weak forms allow faster implementation on mach<strong>in</strong>es with<br />

load-locked/load-l<strong>in</strong>ked/load-and-reserve and store conditional<br />

<strong>in</strong>structions — <strong>in</strong>stead of atomic compare and exchange.<br />

The load-locked type of <strong>in</strong>structions are described below but <strong>the</strong> ide<br />

and ta is to split <strong>the</strong> atomic operation <strong>in</strong>to two <strong>in</strong>structions.<br />

A processor P first performs a load-locked and <strong>the</strong>n a store<br />

conditional.<br />

If a different processor Q performs a store between <strong>the</strong> load-locked<br />

and store conditional made by P, <strong>the</strong>n <strong>the</strong> store conditional made by<br />

P fails.<br />

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

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

Saved successfully!

Ooh no, something went wrong!