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

             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-

     swapcontext(3), intro(9), mutex(9), spl(9)

NetBSD 5.0.1                     May 21, 2007                     NetBSD 5.0.1

You can also request any man page by name and (optionally) by section:


Use the DEFAULT collection to view manual pages for third-party software.

©1994 Man-cgi 1.15, Panagiotis Christias
©1996-2018 Modified for NetBSD by Kimmo Suominen