xref: /netbsd-src/share/man/man9/delay.9 (revision e1d48e5a8b948f1104e684778047f27bffd7e30c)
1*e1d48e5aSsimonb.\"     $NetBSD: delay.9,v 1.8 2021/05/31 12:24:15 simonb Exp $
2fc810034Sgmcgarry.\"
3fc810034Sgmcgarry.\" Copyright (c) 2002 The NetBSD Foundation, Inc.
4fc810034Sgmcgarry.\" All rights reserved.
5fc810034Sgmcgarry.\"
6fc810034Sgmcgarry.\" This code is derived from software contributed to The NetBSD Foundation
7fc810034Sgmcgarry.\" by Gregory McGarry.
8fc810034Sgmcgarry.\"
9fc810034Sgmcgarry.\" Redistribution and use in source and binary forms, with or without
10fc810034Sgmcgarry.\" modification, are permitted provided that the following conditions
11fc810034Sgmcgarry.\" are met:
12fc810034Sgmcgarry.\" 1. Redistributions of source code must retain the above copyright
13fc810034Sgmcgarry.\"    notice, this list of conditions and the following disclaimer.
14fc810034Sgmcgarry.\" 2. Redistributions in binary form must reproduce the above copyright
15fc810034Sgmcgarry.\"    notice, this list of conditions and the following disclaimer in the
16fc810034Sgmcgarry.\"    documentation and/or other materials provided with the distribution.
17fc810034Sgmcgarry.\"
18fc810034Sgmcgarry.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19fc810034Sgmcgarry.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20fc810034Sgmcgarry.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21fc810034Sgmcgarry.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22fc810034Sgmcgarry.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23fc810034Sgmcgarry.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24fc810034Sgmcgarry.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25fc810034Sgmcgarry.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26fc810034Sgmcgarry.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27fc810034Sgmcgarry.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28fc810034Sgmcgarry.\" POSSIBILITY OF SUCH DAMAGE.
29fc810034Sgmcgarry.\"
300ead7c26Sjruoho.Dd July 20, 2011
31fc810034Sgmcgarry.Dt DELAY 9
32fc810034Sgmcgarry.Os
33fc810034Sgmcgarry.Sh NAME
34fc810034Sgmcgarry.Nm delay ,
35fc810034Sgmcgarry.Nm DELAY
36fc810034Sgmcgarry.Nd microsecond delay
37fc810034Sgmcgarry.Sh SYNOPSIS
38*e1d48e5aSsimonb.In sys/param.h
39fc810034Sgmcgarry.Ft void
40fc810034Sgmcgarry.Fn delay "unsigned int us"
41fc810034Sgmcgarry.Ft void
42fc810034Sgmcgarry.Fn DELAY "unsigned int us"
43fc810034Sgmcgarry.Sh DESCRIPTION
44fc810034SgmcgarryWait approximately
45fc810034Sgmcgarry.Fa us
46fc810034Sgmcgarrymicroseconds.
4742fef49bSgmcgarry.Pp
4842fef49bSgmcgarryThe delay is implemented as a machine loop, preventing events other than
4942fef49bSgmcgarryinterrupt handlers for unmasked interrupts to run.
5042fef49bSgmcgarry.Fn DELAY
512bd7624bSgmcgarryis reentrant (doesn't modify any global kernel or machine state) and is
522bd7624bSgmcgarrysafe to use in interrupt or process context.
5342fef49bSgmcgarry.Pp
5453d643b5SadFor long delays, condition variables
5553d643b5Sadshould be considered, however they can only be used from process context
5653d643b5Sadand their resolution is limited by the system clock frequency.
5742fef49bSgmcgarry.Sh SEE ALSO
5853d643b5Sad.Xr condvar 9 ,
590ead7c26Sjruoho.Xr hz 9 ,
600ead7c26Sjruoho.Xr kpause 9
61