Re: [RFC] A more general timeout specification

Andi Kleen
2005-05-18T23:49:19Z

Joe Korty <joe.korty@ccur.com> writes:

> 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'.

If you do a new structure for this I would suggest adding a
"precision" field (or the same with a different name). Basically
precision would tell the kernel that the wakeup can be in a time
range, not necessarily on the exact time specified. This helps
optimizing the idle loop because you can batch timers better and is
important for power management and virtualized environments. The
kernel internally does not use support this yet, but there are plans
to change the internal timers in this direction and if you're defining
a new user interface I would add support for this.

I am not sure precision would be the right name, other suggestions
are welcome.

> 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

It is also useful to avoid code duplication in compat.

-Andi