NetBSD/share/man/man9/splraiseipl.9

104 lines
3.2 KiB
Groff

.\" $NetBSD: splraiseipl.9,v 1.9 2018/02/08 09:03:23 dholland Exp $
.\"
.\" Copyright (c)2006 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 July 9, 2015
.Dt SPLRAISEIPL 9
.Os
.\" ------------------------------------------------------------
.Sh NAME
.Nm splraiseipl
.Nd raise the system priority level
.\" ------------------------------------------------------------
.Sh SYNOPSIS
.In sys/intr.h
.\" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
.Ft int
.Fn splraiseipl \
"ipl_cookie_t icookie"
.\" ------------------------------------------------------------
.Sh DESCRIPTION
.Fn splraiseipl
raises the system priority level to the level specified by
.Fa icookie .
.Fa icookie
should be a value returned by
.Fn makeiplcookie .
.Pp
In general, device drivers should not make use of this interface.
To ensure correct synchronization, device drivers should use the
.Xr condvar 9 ,
.Xr mutex 9 ,
and
.Xr rwlock 9
interfaces.
.Pp
See the
.Xr spl 9
manual page for a description of interrupt priority levels.
.\" ------------------------------------------------------------
.Sh RETURN VALUES
.Fn splraiseipl
returns saved priority level which can be used for
.Fn splx .
.\" ------------------------------------------------------------
.Sh EXAMPLES
The following two lines are functional equivalents.
.Bd -literal
s = splraiseipl(makeiplcookie(IPL_VM));
.Ed
.Bd -literal
s = splvm();
.Ed
.Pp
Because
.Fn makeiplcookie
can be slow and is not expected to be used in a performance critical path,
it's better to do it beforehand.
.Bd -literal
initialization_code(ipl_t ipl)
{
ourcookie = makeiplcookie(ipl);
}
performance_critical_code()
{
int s;
s = splraiseipl(ourcookie);
do_something();
splx(s);
}
.Ed
.\" ------------------------------------------------------------
.Sh SEE ALSO
.Xr condvar 9 ,
.Xr makeiplcookie 9 ,
.Xr mutex 9 ,
.Xr rwlock 9 ,
.Xr spl 9