cpu_switchto(9) - NetBSD Manual Pages

Command: Section: Arch: Collection:  
CPU_SWITCHTO(9)        NetBSD Kernel Developer's Manual        CPU_SWITCHTO(9)

cpu_switchto -- machine-dependent LWP context switching interface
#include <sys/cpu.h> lwp_t * cpu_switchto(lwp_t *oldlwp, lwp_t *newlwp, bool returning);
cpu_switchto() 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. oldlwp Specify the lwp from which we are going to switch, 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 we are going 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 inter- rupt 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.
cpu_switchto() 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 exit- ing.
swapcontext(3), intro(9), mutex(9), spl(9) NetBSD 5.0.1 May 21, 2007 NetBSD 5.0.1
Powered by man-cgi (2021-06-01). Maintained for NetBSD by Kimmo Suominen. Based on man-cgi by Panagiotis Christias.