.TH drv_hztousec() "" "" "DDI/DKI Kernel Routine"
.PC "Convert clock ticks into microseconds"
.B "#include <sys/types.h>"
.B "#include <sys/ddi.h>"
\fBclock_t drv_hztousec(\fIticks\^\fB)\fR
\fBclock_t \fIticks\^\fB;\fR
.PP
.B drv_hztousec()
returns the number of microseconds equivalent to
.IR ticks ,
which is in units of clock ticks.
To convert between clock ticks and microseconds,
use
.BR drv_usectohz() .
.PP
Several functions either take arguments in ticks,
or return time in ticks.
The length of a tick varies among operating systems;
therefore, you should not hard-code any assumption about the length of a tick
into your driver.
.SH "See Also"
.B
DDI/DKI kernel routines,
delay(),
drv_getparm(),
drv_usectohz(),
dtimeout(),
itimeout()
.R
.SH Notes
.B drv_hztousec
has base or interrupt level.
It does not sleep.
.PP
A driver can hold a
driver-defined basic lock, read/write lock, or sleep lock
across a call to this function.
.PP
If a
.B clock_t
is too small to hold the number of microseconds equivalent to
.IR ticks ,
.B drv_hztousec()
returns then the maximum value of
.BR clock_t .
Calling
.B drv_getparm()
with a parameter of
.B LBOLT
often returns a value whose equivalent in microseconds is
too large to fit into a
.BR clock_t .
If you wish to use
.B drv_getparm()
and
.B drv_hztousec()
to time an operation, you should subtract the values returned by
successive calls to
.BR drv_getparm()
and convert the difference,
instead of converting the values and then performing the subtraction.
