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.

57<br />

2.3.1 Kernel threads<br />

Up until now, we have discussed <strong>the</strong> rump kernel context <strong>of</strong> threads which are created<br />

by <strong>the</strong> client, typically by calling pthread_create(). In addition, kernel threads<br />

exist. <strong>The</strong> creation <strong>of</strong> a kernel thread is initiated by <strong>the</strong> kernel <strong>and</strong> <strong>the</strong> entry point<br />

lies within <strong>the</strong> kernel. <strong>The</strong>refore, a kernel thread always executes within <strong>the</strong> kernel<br />

except when it makes a hypercall. Kernel threads are associated with process 0<br />

(struct proc0). An example <strong>of</strong> a kernel thread is <strong>the</strong> workqueue worker thread,<br />

which <strong>the</strong> workqueue kernel subsystem uses to schedule <strong>and</strong> execute asynchronous<br />

work units.<br />

On a regular system, both an application process thread <strong>and</strong> a kernel thread have<br />

<strong>the</strong>ir hard context created by <strong>the</strong> kernel. As we mentioned before, a rump kernel<br />

cannot create a hard context. <strong>The</strong>refore, whenever kernel thread creation is requested,<br />

<strong>the</strong> rump kernel creates <strong>the</strong> s<strong>of</strong>t context <strong>and</strong> uses a hypercall to request<br />

<strong>the</strong> hard context from <strong>the</strong> host. <strong>The</strong> entry point given to <strong>the</strong> hypercall is a bouncer<br />

routine inside <strong>the</strong> rump kernel. <strong>The</strong> bouncer first associates <strong>the</strong> kernel thread’s s<strong>of</strong>t<br />

context with <strong>the</strong> newly created host thread <strong>and</strong> <strong>the</strong>n proceeds to call <strong>the</strong> thread’s<br />

actual entry point.<br />

2.3.2 A CPU for a Thread<br />

First, let us use broad terms to describe how scheduling works in regular virtualized<br />

setup. <strong>The</strong> hypervisor has an idle CPU it wants to schedule work onto <strong>and</strong> it<br />

schedules a guest system. While <strong>the</strong> guest system is running, <strong>the</strong> guest system<br />

decides which guest threads to run <strong>and</strong> when to run <strong>the</strong>m using <strong>the</strong> guest system’s<br />

scheduler. This means that <strong>the</strong>re are two layers <strong>of</strong> schedulers involved in scheduling<br />

a guest thread.

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

Saved successfully!

Ooh no, something went wrong!