Re: FW: [RFC] A more general timeout specification

john stultz
2005-08-22T22:56:55Z

On Thu, 2005-07-28 at 18:52 -0700, Inaky Perez-Gonzalez wrote:
> The main user of this new inteface is to allow system calls to get
> time specified in an absolute form (as most of POSIX states) and thus
> avoid extra time conversion work.
>
> There was a short thread about it, available at google groups
> (grepping for the subject).
>
> http://groups-beta.google.com/groups?q=a+more+general+timeout+specification
>
> Thanks!
>
> [ for comment only ]
>
> The fusyn (robust mutexes) project proposes the creation
> of a more general data structure, 'struct timeout', for the
> specification of timeouts in new services. In this structure,
> the user specifies:
>
> a time, in timespec format.
> the clock the time is specified against (eg, CLOCK_MONOTONIC).
> whether the time is absolute, or relative to 'now'.
>
> That is, all combinations of useful timeout attributes become
> possible.
>
> Also proposed are two new kernel routines for the manipulation
> of timeouts:
>
> timeout_validate()
> timeout_sleep()
>
> timeout_validate() error-checks the syntax of a timeout
> argument and returns either zero or -EINVAL. By breaking
> timeout_validate() out from timeout_sleep(), it becomes possible
> to error check the timeout 'far away' from the places in the
> code where we would actually do the timeout, as well as being
> able to perform such checks only at those places we know the
> timeout specification is coming from an unsafe source.
>
> timeout_sleep() puts the caller to sleep until the
> specified end time is in the past, as measured against
> the given clock, or until the caller is awakened by other
> means (such as wake_up_process()). Like schedule_timeout(),
> TASK_INTERRUPTIBLE or TASK_UNINTERRUPTIBLE must be set ahead
> of time; if TASK_INTERRUPTIBLE is set then signals will also
> break the caller out of the sleep.
>
> timeout_sleep() returns either 0 (returned early) or -ETIMEDOUT
> (returned due to timeout). It is up to the caller to resolve,
> in the "returned early" case, why it returned early.
>
> Timeout_sleep has a return argument, endtime, which is also in
> 'struct timeout' format. If the input time was relative, then
> it is converted to absolute and returned through this argument.
> This can be used when an early-terminated service must be
> restarted and side effects of the early termination-n-restart
> (such as end time drift) are to be avoided.

Hey Inaky, Joe,

Sorry for the terribly slow response. I haven't really dealt too much
with the user-space interfaces for the posix clocks and timers, so I'm
no authority on it. Being able to use absolute values does seem very
important to me, as well as avoiding having glibc make the conversion
using gettimeofday() so that part looks good. I'm not completely sold on
why the validate interface is needed, but I didn't hear any objections
from George, so I'd defer to those who deal more with those interfaces.

Sorry for the lack of insight, although since I haven't heard much on
this recently, maybe this will help stir up the debate?

Nish, do you have any comments on this idea?

thanks
-john