xref: /netbsd-src/share/man/man9/spl.9 (revision 2a399c6883d870daece976daec6ffa7bb7f934ce)
1.\"	$NetBSD: spl.9,v 1.4 1997/11/20 05:47:42 mikel Exp $
2.\"
3.\" Copyright (c) 1997 Michael Long.
4.\" Copyright (c) 1997 Jonathan Stone.
5.\" All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\"    notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\"    notice, this list of conditions and the following disclaimer in the
14.\"    documentation and/or other materials provided with the distribution.
15.\" 3. The name of the author may not be used to endorse or promote products
16.\"    derived from this software without specific prior written permission.
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28.\"
29.Dd March 11, 1997
30.Dt SPL 9
31.Os NetBSD
32.Sh NAME
33.Nm spl ,
34.Nm spl0 ,
35.Nm splbio ,
36.Nm splclock ,
37.Nm splhigh ,
38.Nm splimp ,
39.Nm splnet ,
40.Nm splsched ,
41.Nm splserial ,
42.Nm splsoftclock ,
43.Nm splsoftnet ,
44.Nm splsoftserial ,
45.Nm splstatclock ,
46.Nm spltty ,
47.Nm splx
48.Nd modify system interrupt priority level
49.Sh SYNOPSIS
50.Fd #include <machine/intr.h>
51.Ft int
52.Fn splhigh void
53.Ft int
54.Fn splsched void
55.Ft int
56.Fn splserial void
57.Ft int
58.Fn splclock void
59.Ft int
60.Fn splstatclock void
61.Ft int
62.Fn splimp void
63.Ft int
64.Fn spltty void
65.Ft int
66.Fn splsoftserial void
67.Ft int
68.Fn splnet void
69.Ft int
70.Fn splbio void
71.Ft int
72.Fn splsoftnet void
73.Ft int
74.Fn splsoftclock void
75.Ft int
76.Fn spl0 void
77.Ft void
78.Fn splx "int s"
79.Sh DESCRIPTION
80These functions raise and lower the system priority level.
81They are used by kernel code to block interrupts with priority less
82than or equal to the named level (e.g.
83.Fn spltty
84blocks interrupts of priority less than or equal to
85.Dv IPL_TTY Ns ).
86The code may then safely access variables or data structures which are
87read or modified by interrupt service routines that run at the named
88level.
89.Pp
90A
91.Nm
92function exists for each distinct priority level which can exist in
93the system.  These functions and the corresponding priority levels are
94used for various defined purposes, and may be divided into two main
95types: hard and soft.  Hard interrupts are generated by hardware
96devices.  Soft interrupts are generated by callouts, and are called
97from the kernel's periodic timer interrupt service routine.
98.Pp
99In order of highest to lowest priority, the priority-raising functions
100are:
101.Bl -tag -width splsoftserialXX
102.It Fn splhigh
103blocks all hard and soft interrupts.  It is used for code that cannot
104tolerate any interrupts, like hardware context switching code and
105the
106.Xr ddb 4
107in-kernel debugger.
108.It Fn splserial
109blocks hard interrupts from serial interfaces.  Code running at this
110level may not access the tty subsystem.
111.It Fn splsched
112blocks interrupts that may access scheduler data structures.  Code
113running at or above this level may not call
114.Fn sleep ,
115.Fn tsleep ,
116or
117.Fn wakeup ,
118nor may it post signals.
119.It Fn splclock
120blocks the hardware clock interrupt.  It is used by
121.Fn hardclock
122to update kernel and process times, and must be used by any other code
123that accesses time-related data.
124.It Fn splstatclock
125blocks the hardware statistics clock interrupt.  It is used by
126.Fn statclock
127to update kernel profiling and other statistics, and must be used by
128any code that accesses that data.
129This level is identical to
130.Fn splclock
131if there is no separate statistics clock.
132.It Fn splimp
133blocks hard interrupts from all devices that are allowed to use the
134kernel
135.Xr malloc 9 .
136That includes all disk, network, and tty device interrupts.
137.It Fn spltty
138blocks hard interrupts from TTY devices.
139.It Fn splsoftserial
140blocks soft interrupts generated by serial devices.
141.It Fn splnet
142blocks hard interrupts from network interfaces.
143.It Fn splbio
144blocks hard interrupts from disks and other mass-storage devices.
145.It Fn splsoftnet
146blocks soft network interrupts.
147.El
148.Pp
149Two functions lower the system priority level.  They are:
150.Bl -tag -width splsoftclockXX
151.It Fn splsoftclock
152unblocks all interrupts but the soft clock interrupt.
153.It Fn spl0
154unblocks all interrupts.
155.El
156.Pp
157The
158.Fn splx
159function restores the system priority level to the one encoded in
160.Fa s ,
161which must be a value previously returned by one of the other
162.Nm
163functions.
164