On Thu, 2008-09-11 at 23:50 +0200, Juliusz Chroboczek wrote:
> > For timeouts in select/poll/sleep/timers in general one wants
> > a steady clock without jumps. And times(2) is the only portable
> > sys-call I know of.  BTW do we have requirements on precision?
> 
> In Babel, I use clock_gettime(CLOCK_MONOTONIC) if it's available

clock_gettime(CLOCK_MONOTONIC) is probably the way to go - newer
interfaces tend to avoid such design mistakes.

> (Linux 2.6, FreeBSD 5 and later, OS X 10.4 and later).  If it isn't,

And thus it is IMHO portable enough. Hmm, Win32 needs to be checked.

> I fall back to gettimeofday, with some code to detect clock stepping
> and recover gracefully.

Falling back to times(2) is simpler IMHO (even if one gets more
calculation overhead to from clock-ticks to millisecs/nanosecs or
whatever).

	Bernd
-- 
Firmix Software GmbH                   http://www.firmix.at/
mobil: +43 664 4416156                 fax: +43 1 7890849-55
          Embedded Linux Development and Services




