xref: /netbsd-src/share/man/man9/kpreempt.9 (revision 2ef24fabcc1ee1c13b1153f0f543f55e6a93a96f)
1.\"	$NetBSD: kpreempt.9,v 1.3 2010/02/16 19:21:30 rmind Exp $
2.\"
3.\" Copyright (c)2008 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 February 16, 2010
29.Dt KPREEMPT 9
30.Os
31.\" ------------------------------------------------------------
32.Sh NAME
33.Nm kpreempt
34.Nd control kernel preemption
35.\" ------------------------------------------------------------
36.Sh SYNOPSIS
37.In sys/systm.h
38.\" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
39.Ft void
40.Fn kpreempt_disable \
41"void"
42.Ft void
43.Fn kpreempt_enable \
44"void"
45.Ft bool
46.Fn kpreempt_disabled \
47"void"
48.\" ------------------------------------------------------------
49.Sh DESCRIPTION
50These functions are used to control kernel preemption of the calling LWP.
51.Pp
52On architectures where kernel preemption is not supported natively, these
53functions may still be used.
54.Pp
55It should be noted that kernel preemption is also disabled when holding
56the interrupt priority level above IPL_NONE, e.g. using
57.Xr spl 9
58or spinning
59.Xr mutex 9
60calls or holding kernel_lock (indicating that the code is not MT safe).
61.Pp
62.Fn kpreempt_disable
63disables kernel preemption of the calling LWP.
64Note that disabling kernel preemption can prevent LWPs with higher priorities
65from running.
66.Pp
67.Fn kpreempt_enable
68enables kernel preemption of the calling LWP, which was previously disabled by
69.Fn kpreempt_disable .
70.Pp
71.Fn kpreempt_disable
72and
73.Fn kpreempt_enable
74can be nested.
75.Pp
76.Fn kpreempt_disabled
77returns
78.Dv true
79if preemption of the calling LWP is disabled.
80It is only for diagnostic purpose.
81.\" ------------------------------------------------------------
82.\" .Sh RETURN VALUES
83.\" ------------------------------------------------------------
84.Sh SEE ALSO
85.Xr intro 9 ,
86.Xr mutex 9 ,
87.Xr spl 9
88