| CPU_SWITCHTO(9) | Kernel Developer's Manual | CPU_SWITCHTO(9) |
cpu_switchto —
#include <sys/cpu.h>
lwp_t *
cpu_switchto(lwp_t
*oldlwp, lwp_t
*newlwp, bool
returning);
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:
cpu_switchto() does not switch address
spaces.cpu_switchto() sets
curlwp(9) to
newlwp. If the architecture does non-interlocked
adaptive mutex release, cpu_switchto() does an
equivalent of
membar_producer(3),
before and after the modification of
curlwp(9).cpu_switchto() should be called at
IPL_SCHED. When the function returns, the caller
should lower the priority level as soon as possible.cpu_switchto() might be called with spin mutexes
held.The function takes the following arguments.
NULL, the context of the
LWP currently running on this processor is not saved.NULL.cpu_switchto() function does not return until
another LWP calls cpu_switchto(). It returns the
oldlwp argument of the
cpu_switchto() which is called to switch back to our
LWP. It is either a LWP which called cpu_switchto() to
switch to us or NULL in case the LWP was exiting.
| June 2, 2011 | NetBSD 9.3 |