Date: Mon, 19 Aug 2002 08:29:20 -0700 (PDT) From: Kevin Martin <sigma@pair.com> To: freebsd-gnats-submit@FreeBSD.org Subject: kern/41781: clock_getres returns tv_nsec=0 when TSC is 1Ghz or faster Message-ID: <200208191529.g7JFTKSe066376@www.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 41781
>Category: kern
>Synopsis: clock_getres returns tv_nsec=0 when TSC is 1Ghz or faster
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Mon Aug 19 08:30:02 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: Kevin Martin
>Release: 4.6-STABLE
>Organization:
pair Networks, Inc
>Environment:
FreeBSD vondu.pair.com 4.6-STABLE FreeBSD 4.6-STABLE #12: Mon Aug 19 10:08:01 GMT 2002 sigma@vondu.pair.com:/usr/src/sys/compile/PAIRa i386
>Description:
When the the TSC timer is 1Ghz or faster:
Timecounter "TSC" frequency 1002275326 Hz
kern/kern_time.c handles clock_getres by dividing this value into
1000000000L. The integer result is unfortunately zero. Programs
which expect a useful result are disappointed. For example, PGP uses
this value and divides by it, promptly dumping core.
>How-To-Repeat:
#include <sys/time.h>
#include <stdio.h>
main()
{
struct timespec res;
clock_getres(CLOCK_REALTIME, &res);
printf("%u\n",(unsigned)res.tv_nsec);
}
gcc -o test test.c
./test
>Fix:
I believe the best solution is to return a minimum value of one
nanosecond, since the worst you've done is tell the calling program
that the timer is less precise than it is. Does POSIX have anything
to say? I don't know.
>Release-Note:
>Audit-Trail:
>Unformatted:
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200208191529.g7JFTKSe066376>
