97 lines
3.2 KiB
Groff
97 lines
3.2 KiB
Groff
.\" $NetBSD: cpu_switchto.9,v 1.6 2007/04/21 17:52:09 yamt Exp $
|
|
.\"
|
|
.\" Copyright (c)2007 YAMAMOTO Takashi,
|
|
.\" All rights reserved.
|
|
.\"
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
.\" modification, are permitted provided that the following conditions
|
|
.\" are met:
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
.\"
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
.\" SUCH DAMAGE.
|
|
.\"
|
|
.\" ------------------------------------------------------------
|
|
.Dd April 18, 2007
|
|
.Dt CPU_SWITCHTO 9
|
|
.Os
|
|
.\" ------------------------------------------------------------
|
|
.Sh NAME
|
|
.Nm cpu_switchto
|
|
.Nd machine-dependent LWP context switching interface
|
|
.\" ------------------------------------------------------------
|
|
.Sh SYNOPSIS
|
|
.In sys/cpu.h
|
|
.\" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
.Ft lwp_t *
|
|
.Fn cpu_switchto \
|
|
"lwp_t *oldlwp" "lwp_t *newlwp"
|
|
.\" ------------------------------------------------------------
|
|
.Sh DESCRIPTION
|
|
.Fn cpu_switchto
|
|
saves the context of the LWP which is currenly running on the processor,
|
|
and restores the context of the LWP specified by
|
|
.Fa newlwp .
|
|
.Pp
|
|
.Fn cpu_switchto
|
|
doesn't switch address spaces.
|
|
.Pp
|
|
.Fn cpu_switchto
|
|
sets
|
|
.Dv curlwp
|
|
to
|
|
.Fa newlwp .
|
|
.Pp
|
|
.Fn cpu_switchto
|
|
should be called at
|
|
.Dv IPL_SCHED .
|
|
When
|
|
.Fn cpu_switchto
|
|
returns, the caller should lower the priority level as soon as possible.
|
|
.Pp
|
|
.Fn cpu_switchto
|
|
might be called with spin mutexes held.
|
|
.Pp
|
|
It takes the following arguments.
|
|
.Bl -tag -width oldlwp
|
|
.It Fa oldlwp
|
|
Specify the lwp from which we are going to switch, i.e.,
|
|
the calling LWP.
|
|
If it was
|
|
.Dv NULL ,
|
|
the context of the LWP currently running on this processor is not saved.
|
|
.It Fa newlwp
|
|
Specify the lwp to which we are going to switch.
|
|
It must not be
|
|
.Dv NULL .
|
|
.El
|
|
.\" ------------------------------------------------------------
|
|
.Sh RETURN VALUES
|
|
.Fn cpu_switchto
|
|
does not return until another LWP calls
|
|
.Fn cpu_switchto
|
|
to switch to us.
|
|
It returns an lwp from which we have been switched, i.e.,
|
|
an LWP which called
|
|
.Fa cpu_switchto
|
|
to switch to us.
|
|
.\" ------------------------------------------------------------
|
|
.Sh SEE ALSO
|
|
.Xr swapcontext 3 ,
|
|
.Xr intro 9 ,
|
|
.Xr mutex 9 ,
|
|
.Xr spl 9
|