'\" te .\" Copyright (c) 2001, Sun Microsystems, Inc. All Rights Reserved. .\" Copyright 1989 AT&T .TH delay 9F "15 Oct 2001" "SunOS 5.11" "Kernel Functions for Drivers" .SH NAME delay \- delay execution for a specified number of clock ticks .SH SYNOPSIS .LP .nf #include \fBvoid\fR \fBdelay\fR(\fBclock_t\fR \fIticks\fR); .fi .SH INTERFACE LEVEL .sp .LP Architecture independent level 1 (DDI/DKI). .SH PARAMETERS .sp .ne 2 .mk .na \fB\fIticks\fR \fR .ad .RS 10n .rt The number of clock cycles to delay. .RE .SH DESCRIPTION .sp .LP \fBdelay()\fR provides a mechanism for a driver to delay its execution for a given period of time. Since the speed of the clock varies among systems, drivers should base their time values on microseconds and use \fBdrv_usectohz\fR(9F) to convert microseconds into clock ticks. .sp .LP \fBdelay()\fR uses \fBtimeout\fR(9F) to schedule an internal function to be called after the specified amount of time has elapsed. \fBdelay()\fR then waits until the function is called. Because \fBtimeout()\fR is subject to priority inversion, drivers waiting on behalf of processes with real-time constraints should use \fBcv_timedwait\fR(9F) rather than \fBdelay()\fR. .sp .LP \fBdelay()\fR does not busy-wait. If busy-waiting is required, use \fBdrv_usecwait\fR(9F). .SH CONTEXT .sp .LP \fBdelay()\fR can be called from user and kernel contexts. .SH EXAMPLES .LP \fBExample 1 \fR\fBdelay()\fR Example .sp .LP Before a driver I/O routine allocates buffers and stores any user data in them, it checks the status of the device (line 12). If the device needs manual intervention (such as, needing to be refilled with paper), a message is displayed on the system console (line 14). The driver waits an allotted time (line 17) before repeating the procedure. .sp .in +2 .nf 1 struct device { /* layout of physical device registers */ 2 int control; /* physical device control word */ 3 int status; /* physical device status word */ 4 short xmit_char; /* transmit character to device */ 5 }; 6 7 . . . 9 /* get device registers */ 10 register struct device *rp = ... 11 12 while (rp->status & NOPAPER) { /* while printer is out of paper */ 13 /* display message and ring bell */ /* on system console */ 14 cmn_err(CE_WARN, "^\e007", 15 (getminor(dev) & 0xf)); 16 /* wait one minute and try again */ 17 delay(60 * drv_usectohz(1000000)); 18 } .fi .in -2 .SH SEE ALSO .sp .LP \fBbiodone\fR(9F), \fBbiowait\fR(9F), \fBcv_timedwait\fR(9F), \fBddi_in_panic\fR(9F), \fBdrv_hztousec\fR(9F), \fBdrv_usectohz\fR(9F), \fBdrv_usecwait\fR(9F), \fBtimeout\fR(9F), \fBuntimeout\fR(9F) .sp .LP \fIWriting Device Drivers for Oracle Solaris 11.2\fR