DRV_USECTOHZ(9F) Kernel Functions for Drivers DRV_USECTOHZ(9F)
drv_usectohz - convert microseconds to clock ticks
#include <sys/ddi.h> clock_t drv_usectohz
Architecture independent level 1 (DDI/DKI).
The number of microseconds to convert.
function converts a length of time expressed in
microseconds to a number of system clock ticks. The time arguments to timeout(9F)
are expressed in clock ticks.
function is a portable interface for drivers to make
calls to timeout(9F)
and remain binary compatible should
the driver object file be used on a system with a different clock speed
(a different number of ticks in a second).
The value returned is the number of system clock ticks equivalent to the microsecs
argument. No error value is returned. If the clock tick
equivalent to microsecs
is too large to be represented as a clock_t
the maximum clock_t
value will be returned.
function can be called from user, interrupt, or kernel
SEE ALSO delay(9F)
, timeout(9F) Writing Device Drivers
If the microsecs
argument to drv_usectohz()
is less than drv_hztousec(9F)
returns one tick. This, coupled with
multiplication, can result in significantly longer durations than
expected. For example, on a machine where hz
is 100, calling drv_usectohz()
with a microsecs
value less than 10000 returns a result
equivalent to 10000 (1 tick). This type of mistake causes code such
as"5000 * drv_usectohz(1000)
" to compute a duration of 50 seconds instead
of the intended 5 seconds.
April 24, 2008 DRV_USECTOHZ(9F)