Beispiel #1
0
/*
 * rump_schedule: ensure that the calling host thread has a valid lwp context.
 * ie. ensure that curlwp != NULL.  Also, ensure that there
 * a 1:1 mapping between the lwp and rump kernel cpu.
 */
void
rump_schedule()
{
    struct lwp *l;

    /*
     * If there is no dedicated lwp, allocate a temp one and
     * set it to be free'd upon unschedule().  Use lwp0 context
     * for reserving the necessary resources.  Don't optimize
     * for this case -- anyone who cares about performance will
     * start a real thread.
     */
    if (__predict_true((l = curlwp) != NULL)) {
        rump_schedule_cpu(l);
        LWP_CACHE_CREDS(l, l->l_proc);
    } else {
        lwp0busy();

        /* schedule cpu and use lwp0 */
        rump_schedule_cpu(&lwp0);
        rump_lwproc_curlwp_set(&lwp0);

        /* allocate thread, switch to it, and release lwp0 */
        l = rump__lwproc_alloclwp(initproc);
        rump_lwproc_switch(l);
        lwp0rele();

        /*
         * mark new thread dead-on-unschedule.  this
         * means that we'll be running with l_refcnt == 0.
         * relax, it's fine.
         */
        rump_lwproc_releaselwp();
    }
}
Beispiel #2
0
void
rump_pub_lwproc_releaselwp(void)
{

	rump_schedule();
	rump_lwproc_releaselwp();
	rump_unschedule();
}