28.08.2015 Views

The Design and Implementation of the Anykernel and Rump Kernels

1F3KDce

1F3KDce

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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

A–24<br />

RUMP_LWPROC(3) NetBSD Library Functions Manual RUMP_LWPROC(3)<br />

rump kernels as well, but since rump uses <strong>the</strong> host’s thread <strong>and</strong> process<br />

context directly, <strong>the</strong> rules for how thread context is determined are different.<br />

In <strong>the</strong> rump model, each host thread (pthread) is ei<strong>the</strong>r bound to a rump<br />

kernel lwp or accesses <strong>the</strong> rump kernel with an implicit thread context<br />

associated with pid 1. An implicit thread context is created every time<br />

<strong>the</strong> rump kernel is entered <strong>and</strong> disb<strong>and</strong>ed upon exit. While convenient for<br />

occasional calls, creating an implicit thread uses a shared resource<br />

which can become highly contended in a multithreaded situation. It is<br />

<strong>the</strong>refore recommended that dedicated threads are created.<br />

<strong>The</strong> association between host threads <strong>and</strong> <strong>the</strong> rump kernel curlwp is left<br />

to <strong>the</strong> caller. It is possible to create a dedicated host thread for<br />

every rump kernel lwp or multiplex <strong>the</strong>m on top <strong>of</strong> a single host thread.<br />

After rump lwps have been created, switching curlwp is very cheap --<br />

faster than a thread context switch on <strong>the</strong> host. In case multiple<br />

lwps/processes are created, it is <strong>the</strong> caller’s responsibility to keep<br />

track <strong>of</strong> <strong>the</strong>m <strong>and</strong> release <strong>the</strong>m when <strong>the</strong>y are no longer necessary. Like<br />

o<strong>the</strong>r rump kernel resources, procs/lwps will be released when <strong>the</strong> process<br />

hosting <strong>the</strong> rump kernel exits.<br />

rump_pub_lwproc_rfork()<br />

Create a process, one lwp inside it <strong>and</strong> set curlwp to <strong>the</strong> new lwp.<br />

<strong>The</strong> flags parameter controls how file descriptors are inherited<br />

from <strong>the</strong> parent. By default (flags=0) file descriptors are shared.<br />

O<strong>the</strong>r options are:<br />

RUMP_RFFDG Copy file descriptors from parent. This is what<br />

fork(2) does.<br />

NetBSD 5.99.48 January 2, 2011 NetBSD 5.99.48

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

Saved successfully!

Ooh no, something went wrong!