tvtohz() was originally designed for tsleep() and timeout() operations but
it is also used to time nanosleep() ops. The problem is that in order to
compensate for the fact that a clock interrupt might occur just after a
thread blocks or registers a timeout, this function effectively added +1
to the returned value plus added another +1 for timeouts that were not
integer multiples if the clock interrupt frequency.
Split tvtohz() into two routines: tvtohz_low() and tvtohz_high().
tvtohz_low() does not do any compensation, tvtohz_high() does.
Add the kern.sleep_hardloop sysctl, which defaults to 0 (off). If set to
1 this will cause nanosleep() to attempt to time exactly the requested
interval (which could cost more cpu) rather then rounding it off to a
multiple of hz. If set to 2 nanosleep() will only do the more rigid
timing for requests less then 1 second. Also change the normal hz-baesd
case to only compensate by +1, not +2, in order to improve accuracy.
16 files changed: