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.

From <strong>the</strong> L<strong>in</strong>ux Kernel Documentation<br />

rcu_dereference()<br />

typeof(p) rcu_dereference(p);<br />

Like rcu_assign_po<strong>in</strong>ter(), rcu_dereference() must be implemented<br />

as a macro.<br />

The reader uses rcu_dereference() to fetch an RCU-protected<br />

po<strong>in</strong>ter, which returns a value that may <strong>the</strong>n be safely<br />

dereferenced. Note that rcu_deference() does not actually<br />

dereference <strong>the</strong> po<strong>in</strong>ter, <strong>in</strong>stead, it protects <strong>the</strong> po<strong>in</strong>ter for<br />

later dereferenc<strong>in</strong>g. It also executes any needed memory-barrier<br />

<strong>in</strong>structions for a given CPU architecture. Currently, only Alpha<br />

needs memory barriers with<strong>in</strong> rcu_dereference() -- on o<strong>the</strong>r CPUs,<br />

it compiles to noth<strong>in</strong>g, not even a compiler directive.<br />

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

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

Saved successfully!

Ooh no, something went wrong!