drv_usecwait(9F)
NAME
drv_usecwait − busy-wait for specified interval
SYNOPSIS
#include <sys/types.h>
#include <sys/ddi.h>
void drv_usecwait(clock_t microsecs);
ARGUMENTS
microsecs The number of microseconds to busy-wait.
INTERFACE LEVEL
Architecture independent level 1 (DDI/DKI).
DESCRIPTION
drv_usecwait() 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 (given by parameter HZ in sys/param.h, which indicates how many system ticks occur per second). There are two limitations: first, the granularity of the wait time is limited to 1/HZ second, which may be more time than is needed for the delay; and second, delay(9F) may only be invoked with user 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 with user context, delay(9F) produces too long a wait period.
Note that the driver wastes processor time by making this call since drv_usecwait() does not invoke sleep but simply busy-waits. The driver should only make calls to drv_usecwait() as needed, and only for as much time as needed. drv_usecwait() does not mask out interrupts, but the driver may do so on its own when calling drv_usecwait().
CONTEXT
drv_usecwait() can be called from user or interrupt context.
SEE ALSO
delay(9F), timeout(9F), untimeout(9F)
SunOS 5.1 — Last change: 11 Apr 1991