xref: /netbsd-src/share/man/man9/cpu_switchto.9 (revision 8b0f9554ff8762542c4defc4f70e1eb76fb508fa)
1.\"	$NetBSD: cpu_switchto.9,v 1.8 2007/12/02 19:44:02 wiz Exp $
2.\"
3.\" Copyright (c)2007 YAMAMOTO Takashi,
4.\" All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\"
15.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25.\" SUCH DAMAGE.
26.\"
27.\" ------------------------------------------------------------
28.Dd May 21, 2007
29.Dt CPU_SWITCHTO 9
30.Os
31.\" ------------------------------------------------------------
32.Sh NAME
33.Nm cpu_switchto
34.Nd machine-dependent LWP context switching interface
35.\" ------------------------------------------------------------
36.Sh SYNOPSIS
37.In sys/cpu.h
38.\" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
39.Ft lwp_t *
40.Fn cpu_switchto \
41"lwp_t *oldlwp" "lwp_t *newlwp"
42.\" ------------------------------------------------------------
43.Sh DESCRIPTION
44.Fn cpu_switchto
45saves the context of the LWP which is currently running on the processor,
46and restores the context of the LWP specified by
47.Fa newlwp .
48.Pp
49.Fn cpu_switchto
50doesn't switch address spaces.
51.Pp
52.Fn cpu_switchto
53sets
54.Dv curlwp
55to
56.Fa newlwp .
57.Pp
58.Fn cpu_switchto
59should be called at
60.Dv IPL_SCHED .
61When
62.Fn cpu_switchto
63returns, the caller should lower the priority level as soon as possible.
64.Pp
65.Fn cpu_switchto
66might be called with spin mutexes held.
67.Pp
68It takes the following arguments.
69.Bl -tag -width oldlwp
70.It Fa oldlwp
71Specify the lwp from which we are going to switch, i.e.,
72the calling LWP.
73If it was
74.Dv NULL ,
75the context of the LWP currently running on this processor is not saved.
76.It Fa newlwp
77Specify the lwp to which we are going to switch.
78It must not be
79.Dv NULL .
80.El
81.\" ------------------------------------------------------------
82.Sh RETURN VALUES
83.Fn cpu_switchto
84does not return until another LWP calls
85.Fn cpu_switchto
86to switch to us.
87It returns the
88.Dv oldlwp
89argument of the
90.Fn cpu_switchto
91which is called to switch back to our LWP.
92It's either an LWP which called
93.Fa cpu_switchto
94to switch to us or
95.Dv NULL
96in the case that the LWP was exiting.
97.\" ------------------------------------------------------------
98.Sh SEE ALSO
99.Xr swapcontext 3 ,
100.Xr intro 9 ,
101.Xr mutex 9 ,
102.Xr spl 9
103