The
cpu_switchto() function saves the context of the LWP which is currently running on the processor, and restores the context of the LWP specified by
newlwp.
Remarks:
1.
cpu_switchto() does not switch address spaces.
3.
cpu_switchto() should be called at IPL_SCHED. When the function returns, the caller should lower the priority level as soon as possible.
4.
cpu_switchto() might be called with spin mutexes held.
The function takes the following arguments.
oldlwp
Specify the LWP from which the switch is going to be made, i.e., the calling LWP. If it was NULL, the context of the LWP currently running on this processor is not saved.
newlwp
Specify the LWP to which to switch. It must not be NULL.
returning
Only meaningful if the architecture implements fast software interrupts. If true, it indicates that
oldlwp is a soft interrupt LWP that is blocking. It is a good indication that any kind of address space or user activity can be completely ignored. For example:
ras_lookup(9), 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.