SPL(9)                       OpenBSD Kernel Manual                      SPL(9)

NAME
     spl - modify system interrupt priority level

SYNOPSIS
     #include <machine/intr.h>

     int
     splhigh(void);

     int
     splsched(void);

     int
     splserial(void);

     int
     splclock(void);

     int
     splstatclock(void);

     int
     splimp(void);

     int
     spltty(void);

     int
     splsoftserial(void);

     int
     splnet(void);

     int
     splbio(void);

     int
     splsoftnet(void);

     int
     splsoftclock(void);

     int
     spl0(void);

     void
     splx(int s);

DESCRIPTION
     These functions raise and lower the system priority level.  They are used
     by kernel code running at any given priority level to block higher-prior-
     ity interrupts, so that it can safely access variables or data structures
     which are used by kernel code that runs at a higher priority level.

     A spl function exists for each distinct priority level which can exist in
     the system.  These macros and the corresponding priority levels are used
     for various defined purposes, and may be divided into two main types:
     hard and soft.  Hard interrupts are generated by hardware devices, while
     soft interrupts are generated by callouts and called from the kernel's
     periodic timer interrupt service routine.



     In order of highest to lowest priority, the priority-raising macros are:

     splhigh()        blocks all hard and soft interrupts.  It is used for
                      code that cannot tolerate any interrupts, like hardware
                      context switching code and the ddb(4) in-kernel debug-
                      ger.

     splserial()      blocks hard interrupts from serial interfaces.  Code
                      running at this level may not access the tty subsystem.

     splsched()       blocks interrupts that may access scheduler data struc-
                      tures.  Code running at or above this level may not call
                      sleep(), tsleep(), or wakeup(), nor may it post signals.

     splclock()       blocks the hardware clock interrupt.  It is used by
                      hardclock() to update kernel and process times, and must
                      be used by any other code that accesses time-related da-
                      ta.

     splstatclock()   blocks the hardware statistics clock interrupt.  It is
                      used by statclock() to update kernel profiling and other
                      statistics, and must be used by any code that accesses
                      that data.  This level is identical to splclock() if
                      there is no separate statistics clock.

     splimp()         blocks hard interrupts from all devices that are allowed
                      to use the kernel malloc(9).  That includes all disk,
                      network, and tty device interrupts.

     spltty()         blocks hard interrupts from TTY devices.

     splsoftserial()  blocks soft interrupts generated by serial devices.

     splnet()         blocks hard interrupts from network interfaces.

     splbio()         blocks hard interrupts from disks and other mass-storage
                      devices.

     splsoftnet()     blocks soft network interrupts.

     Two macros lower the system priority level.  They are:

     splsoftclock()  unblocks all interrupts but the soft clock interrupt.

     spl0()          unblocks all interrupts.

     The splx() macro restores the system priority level to the one encoded in
     s, which must be a value previously returned by one of the other spl
     macros.

OpenBSD 2.6                     March 11, 1997                               2
