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.

82<br />

<strong>The</strong> entry point rump_schedule() 6 starts by checking if <strong>the</strong> host thread has a<br />

bound rump kernel thread context. This check maps to consulting <strong>the</strong> host’s thread<br />

local storage with a hypercall. If a value is set, it is used <strong>and</strong> <strong>the</strong> entrypoint can<br />

move to scheduling a CPU.<br />

In case an implicit thread is required, it is necessary to create one. We use <strong>the</strong><br />

system thread lwp0 as <strong>the</strong> bootstrap context for creating <strong>the</strong> implicit thread. Since<br />

<strong>the</strong>re is only one instance <strong>of</strong> this resource, it may be used only by a single consumer<br />

at a time, <strong>and</strong> must be locked before use. After a lock on lwp0 has been obtained,<br />

a CPU is scheduled for it. Next, <strong>the</strong> implicit thread is created <strong>and</strong> it is given <strong>the</strong><br />

same CPU we obtained for lwp0. Finally, lwp0 is unlocked <strong>and</strong> servicing <strong>the</strong> rump<br />

kernel request can begin.<br />

<strong>The</strong> exit point is <strong>the</strong> converse: in case we were using a bound thread, just releasing<br />

<strong>the</strong> CPU is enough. In case an implicit thread was used it must be released. Again,<br />

we need a thread context to do <strong>the</strong> work <strong>and</strong> again we use lwp0. A critical detail is<br />

noting <strong>the</strong> resource acquiry order: <strong>the</strong> CPU must be unscheduled before lwp0 can be<br />

locked. Next, a CPU must be scheduled for lwp0 via <strong>the</strong> normal path. Attempting<br />

to obtain lwp0 while holding on to <strong>the</strong> CPU may lead to a deadlock.<br />

Instead <strong>of</strong> allocating <strong>and</strong> free’ing an implicit context at every entry <strong>and</strong> exit point,<br />

respectively, a possibility is to cache <strong>the</strong>m. Since we assume that all performanceconscious<br />

clients use bound threads, caching would add unwarranted complexity to<br />

<strong>the</strong> code.<br />

6 rump_schedule() / rump_unschedule() are slight misnomers <strong>and</strong> for example rump_enter()<br />

/ rump_exit() would be more descriptive. <strong>The</strong> interfaces are exposed to clients, so changing <strong>the</strong><br />

names is not worth <strong>the</strong> effort anymore.

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

Saved successfully!

Ooh no, something went wrong!