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