On Thu, Dec 13, 2018 at 01:53:00AM +0000, Paul Swanson wrote:
> Hi,
> 
> I'm trying to understand how interval timers work in OpenBSD, but I'm
> a little stuck on this line from the getitimer / setitimer man page:
> 
> "Time values smaller than the resolution of the system clock are rounded
> up to this resolution (typically 10 milliseconds)."
> 
> Does this mean that 10 milliseconds is the shortest interval possible
> with a system interval timer?
> 
> If so, are there other userland options for more precise timers?
> 
> I'm mainly interested in AMD64.

On amd64, where hz(9) is 100, 10 milliseconds is indeed the shortest
interval possible for the per-process itimer(2) timers.  Smaller
intervals will be rounded up to 10ms when the timer is scheduled in
the kernel.

This is the case for all platforms except for alpha (where hz is 1024)
and sh/landisk (where hz is 64).

Other timer interfaces will have the same restriction, e.g. the kevent(2)
EVFILT_TIMER filter has the same granularity as setitimer(2).

There have been proposals to raise the default hz(9) (see e.g. [1]) but
they have not landed.

You can increase HZ if you're compiling a custom kernel.  This would, in
principle, shrink the possible itimer interval.  This is not recommended
unless you really know what you're doing and in general custom kernels are
not supported.

[1] https://marc.info/?l=openbsd-tech&m=150274123011009&w=2

Reply via email to