xref: /illumos-gate/usr/src/man/man9f/drv_usecwait.9f (revision aa693e996c2928c92cccd8a3efe91373e85a6967)
te
Copyright (c) 2006, 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]
DRV_USECWAIT 9F "Jan 16, 2006"
NAME
drv_usecwait - busy-wait for specified interval
SYNOPSIS

#include <sys/types.h>
#include <sys/ddi.h>



void drv_usecwait(clock_t microsecs);
INTERFACE LEVEL

Architecture independent level 1 (DDI/DKI).

PARAMETERS
microsecs

The number of microseconds to busy-wait.

DESCRIPTION

The drv_usecwait() function gives drivers a means of busy-waiting for a specified microsecond count. The amount of time spent busy-waiting may be greater than the microsecond count but will minimally be the number of microseconds specified.

delay(9F) can be used by a driver to delay for a specified number of system ticks, but it has two limitations. First, the granularity of the wait time is limited to one clock tick, which may be more time than is needed for the delay. Second, delay(9F) can be invoked from user or kernel context and hence cannot be used at interrupt time or system initialization.

Often, drivers need to delay for only a few microseconds, waiting for a write to a device register to be picked up by the device. In this case, even in user context, delay(9F) produces too long a wait period.

CONTEXT

The drv_usecwait() function can be called from user, interrupt, or kernel context.

SEE ALSO

delay(9F), timeout(9F), untimeout(9F)

Writing Device Drivers

NOTES

The driver wastes processor time by making this call since drv_usecwait() does not block but simply busy-waits. The driver should only make calls to drv_usecwait() as needed, and only for as much time as needed. The drv_usecwait() function does not mask out interrupts.