28.08.2015 Views

The Design and Implementation of the Anykernel and Rump Kernels

1F3KDce

1F3KDce

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

105<br />

3.5.1 Passive Serialization Techniques<br />

Passive serialization [42] is essentially a variation <strong>of</strong> a reader-writer lock where <strong>the</strong><br />

read side <strong>of</strong> <strong>the</strong> lock is cheap <strong>and</strong> <strong>the</strong> write side <strong>of</strong> <strong>the</strong> lock is expensive, i.e. <strong>the</strong><br />

lock is optimized for readers. It is called passive serialization because readers do<br />

not take an atomic platform level lock. <strong>The</strong> lack <strong>of</strong> a read-side lock is made up<br />

for by deferred garbage collection, where an old copy is released only after it has<br />

reached a quiescent state, i.e. <strong>the</strong>re are no readers accessing <strong>the</strong> old copy. In an<br />

operating system kernel <strong>the</strong> quiescent state is usually established by making <strong>the</strong> old<br />

copy unreachable <strong>and</strong> waiting until all CPUs in <strong>the</strong> system have run code.<br />

An example <strong>of</strong> passive serialization used for example in <strong>the</strong> Linux kernel is <strong>the</strong> readcopy<br />

update (RCU) facility [68]. However, <strong>the</strong> algorithm is patented <strong>and</strong> can be<br />

freely implemented only in GPL or LGPL licensed code. Both licenses are seen as<br />

too restrictive for <strong>the</strong> NetBSD kernel <strong>and</strong> are not allowed by <strong>the</strong> project. <strong>The</strong>refore,<br />

RCU itself cannot be implemented in NetBSD. Ano<strong>the</strong>r example <strong>of</strong> passive serialization<br />

is <strong>the</strong> rmlock (read-mostly lock) facility <strong>of</strong>fered by FreeBSD. It is essentially<br />

a reader/writer locking facility with a lockless fastpath for readers. <strong>The</strong> write locks<br />

are expensive <strong>and</strong> require cross calling o<strong>the</strong>r CPUs <strong>and</strong> running code on <strong>the</strong>m.<br />

Despite <strong>the</strong> lack <strong>of</strong> a locking primitive which is implemented using passive synchronization,<br />

passive synchronization is still used in <strong>the</strong> NetBSD kernel. One example<br />

which was present in NetBSD 5.99.48 is <strong>the</strong> dynamic loading <strong>and</strong> unloading <strong>of</strong> system<br />

calls in sys/kern/kern_syscall.c. <strong>The</strong>se operations require atomic locking<br />

so as to make sure no system call is loaded more than once, <strong>and</strong> also to make<br />

sure a system call is not unloaded while it is still in use. Having to take a regular<br />

lock every time a system call is executed would be wasteful, given that unloading<br />

<strong>of</strong> system calls during runtime takes place relatively seldom, if ever. Instead, <strong>the</strong><br />

implementation uses a passive synchronization algorithm where a lock is used only<br />

for operations which are not performance-critical. We describe <strong>the</strong> elements <strong>of</strong> <strong>the</strong>

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

Saved successfully!

Ooh no, something went wrong!