CPU_SWITCHTO(9) NetBSD Kernel Developer's Manual CPU_SWITCHTO(9)
NAME
cpu_switchto -- machine-dependent LWP context switching interface
SYNOPSIS
#include <sys/cpu.h> lwp_t * cpu_switchto(lwp_t *oldlwp, lwp_t *newlwp, bool returning);
DESCRIPTION
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.
RETURN VALUES
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.
SEE ALSO
swapcontext(3), intro(9), mutex(9), spl(9) NetBSD 5.2.2 May 21, 2007 NetBSD 5.2.2
Powered by man-cgi (2024-08-26). Maintained for NetBSD by Kimmo Suominen. Based on man-cgi by Panagiotis Christias.