lwp_t *
cpu_switchto(lwp_t *oldlwp, lwp_t *newlwp, bool returning)
)
saves the context of the LWP which is currently running on the processor,
and restores the context of the LWP specified by
newlwp.
cpu_switchto()
doesn't switch address spaces.
cpu_switchto()
sets
curlwp
to
newlwp.
cpu_switchto()
should be called at
IPL_SCHED.
When
cpu_switchto()
returns, the caller should lower the priority level as soon as possible.
cpu_switchto()
might be called with spin mutexes held.
It takes the following arguments.
oldlwpNULL,
the context of the LWP currently running on this processor is not saved.
newlwpNULL.
returningoldlwp
is a soft interrupt LWP that is blocking.
It's a good indication that any kind of address space or user activity
can be completely ignored.
For example:
ras_lookup(),
cache flushes, TLB wirings, adjusting lazy FPU
state.
All that is required is to restore the register state and stack, and
return to the interrupted LWP.
)
does not return until another LWP calls
cpu_switchto()
to switch to us.
It returns the
oldlwp
argument of the
cpu_switchto()
which is called to switch back to our LWP.
It's either an LWP which called
cpu_switchto
to switch to us or
NULL
in the case that the LWP was exiting.