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.

Read-Copy Update<br />

RCU is an alternative to readers-writers locks with <strong>the</strong> follow<strong>in</strong>g<br />

essential functionality:<br />

Po<strong>in</strong>ters to data structures are protected with RCU.<br />

Readers use read-side critical sections marked by enter/exit calls.<br />

When a reader is <strong>in</strong> such a section a writer may not modify <strong>the</strong> data<br />

structure but <strong>in</strong>stead modifies a copy of it.<br />

When <strong>the</strong> last reader has left, <strong>the</strong> orig<strong>in</strong>al data structure is updated.<br />

RCU is heavily used <strong>in</strong> <strong>the</strong> L<strong>in</strong>ux kernel.<br />

RCU was one part of <strong>the</strong> SCO vs IBM lawsuit.<br />

From l<strong>in</strong>ux-2.6.37.1/kernel/signal.c<br />

/∗<br />

∗ Protect access to @t credentials . This can go away when all<br />

∗ callers hold rcu read lock .<br />

∗/<br />

rcu_read_lock();<br />

user = get_uid(__task_cred(t)->user);<br />

atomic_<strong>in</strong>c(&user->sigpend<strong>in</strong>g);<br />

rcu_read_unlock();<br />

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

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

Saved successfully!

Ooh no, something went wrong!