summaryrefslogtreecommitdiff
path: root/usr/src/man/man9f/delay.9f
blob: 22e6ab26746f92cdfeaf741e28f98ddb19c8abd7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
'\" te
.\" Copyright (c) 2001, Sun Microsystems, Inc.  All Rights Reserved.
.\" Copyright 1989 AT&T
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
.TH DELAY 9F "Oct 15, 2001"
.SH NAME
delay \- delay execution for a specified number of clock ticks
.SH SYNOPSIS
.LP
.nf
#include <sys/ddi.h>



\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
.na
\fB\fIticks\fR \fR
.ad
.RS 10n
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\fR