Subject: Re: clock(3) possible bug
To: None <root@theforest.plus.com>
From: Jun-ichiro itojun Hagino <itojun@itojun.org>
List: netbsd-bugs
Date: 08/19/2003 13:25:27
> Sometime clock() will appear to lose a tick when really abused (I was
> porting TiLP, and timeouts were occuring regularly).
> 
> I tested using getrusage() which clock() calls. The way that the
> system/user cpu times are added allow for values to be lost enough to drop
> a single (CLOCKS_PER_SEC).
> 
> When the timeval tv_usec/tv_sec values are added separately, it works
> ok. e.g.
> 
> etv.tv_sec=ru.ru_utime.tv_sec + ru.ru_stime.tv_sec;
> etv.tv_usec=ru.ru_utime.tv_usec + ru.ru_stime.tv_usec;
> etv.tv_sec+=etv.tv_usec / 1000000;
> etv.tv_usec=etv.tv_usec % 1000000;
> 
> return((clock_t)(CONVTCK(etv)));
> 
> It is certainly a minor thing, just thought I'd mention it.

	would you please care to file it as a PR, so that we could track it
	down in the future?

itojun