.TH defer() "" "" "Internal Kernel Routine"
.PC "Defer function execution"
\fBvoid defer(\fIfunc\^\fB, \fIarg\^\fB)\fR
\fBvoid (*\fIfunc\^\fB)(); char *\fIarg\^\fB;\fR
.PP
.B defer()
defers execution of the function to which \fIfunc\fR points.
.I arg
is an argument passed to
.IR func .
Execution of
.I func
remains deferred until the next context switch,
transition from kernel to user mode,
or invocation of the function \fBdefend()\fR.
.PP
Deferred functions never call
.B sleep()
or access the
.B u
area, because the kernel can switch
.B u
areas as part of context switching.
Up to 127 functions can be deferred at any one time.
Exceeding this limit may lose all deferred functions.
.PP
.B defer()
normally is used to minimize interrupt latency by deferring operations
from interrupt level (where lower priority interrupts are disabled) to
background level (where all interrupts normally are enabled).
It is also used to help eliminate critical race conditions between
task- and interrupt-related operations
because deferred functions execute synchronously with each other, with timed
functions, and with system calls.
.SH "See Also"
.B
internal kernel routines
.R
