Absolute timeouts and clock adjustments

Eric van Gyzen vangyzen at FreeBSD.org
Fri Feb 24 21:26:31 UTC 2017


> Using CLOCK_MONOTONIC doesn't avoid the issue, it just explicitly asks
> for the current behavior.  If the behavior you need is to wake up when
> CLOCK_REALTIME exceeds some value, you're still screwed.
>
> It would be easy enough to fix the current behavior by adding something
> like "if (timo > hz) timo = hz;" to the existing loop so that
> CLOCK_REALTIME gets re-checked once a second.

That would work, but I don't really like introducing spurious wakeups just to 
handle a very rare event.

How about this approach?

	https://reviews.freebsd.org/D9791

It's also not ideal, and it's obviously much larger than your suggestion, but 
it's very cheap in the common paths.

Eric


More information about the freebsd-hackers mailing list