Subject: Re: Preparing callout(9) for a HZ-less kernel
To: Andrew Doran <>
From: Johnny Billquist <>
List: tech-kern
Date: 10/19/2007 03:06:19
Andrew Doran skrev:
> On Thu, Oct 18, 2007 at 11:47:33PM +0200, Joerg Sonnenberger wrote:
>> On Thu, Oct 18, 2007 at 10:43:11PM +0100, Andrew Doran wrote:
>>> ltsleep/mtsleep are obsoleted by condvars for most uses. I now think I made
>>> a mistake with the condvars and that they should accept an absolute wakeup
>>> time instead of a delta. That's easy enough to do except for handling the
>>> effects of changing the system clock.
>> I think the delta in itself is fine, just the measurement is wrong. I
>> would like to adopt the cv_wait API to use similiar precision as well.
> Consider:
> 	user provides a timeout value
> 	enter timed sleep waiting for a condition to become true
> 	wake up early, find that the condition is still not true
> 	go back to sleep re-using the same timeout value
> If we pass an absolute wakeup time to the sleep routine then the above will
> not sleep longer than requested.

The ugly thing about absolute time is that it can be affected by time changes 
(like you noted), unless we have a guaranteed monotonically increasing clock for 
only this purpose, that can't be "changed". I think it's a rather broken scheme 
if where you can't sleep for a specified time, and be sure that it will actually 
be that much time, independent of if the system time is changed.
However, sometimes you also want to sleep until a specific time occurs, in which 
an absolute time really is preferrable.
Heck, you probably really would want both. Can we do that?

If you use delta times, then you could adopt something similar to nanosleep in 
userland, in which the remaining time can be returned, which can then be used to 
go back to sleep.


Johnny Billquist                  || "I'm on a bus
                                   ||  on a psychedelic trip
email:             ||  Reading murder books
pdp is alive!                     ||  tryin' to stay hip" - B. Idol