Subject: kern/16116: clock_getres(CLOCK_REALTIME) is pessimistic
To: None <gnats-bugs@gnats.netbsd.org>
From: Ben Harris <bjh21@netbsd.org>
List: netbsd-bugs
Date: 03/29/2002 16:48:35
>Number:         16116
>Category:       kern
>Synopsis:       clock_getres(CLOCK_REALTIME) is pessimistic
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Mar 29 08:49:00 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Ben Harris
>Release:        2002-03-28
>Organization:
>Environment:
>Description:

sys_clock_getres() (in sys/kern/kern_time.c) always returns a value based
on hz when asked about CLOCK_REALTIME.  Since sys_clock_gettime() calls
microtime() to get CLOCK_REALTIME, it may actually have a resolution well
above hz.

>How-To-Repeat:

Look at the definition of sys_clock_getres():

        case CLOCK_REALTIME:
        case CLOCK_MONOTONIC:
                ts.tv_sec = 0;
                ts.tv_nsec = 1000000000 / hz;

whereas in sys_clock_gettime():

        case CLOCK_REALTIME:
                microtime(&atv);
                TIMEVAL_TO_TIMESPEC(&atv,&ats);
                break;

>Fix:

Add a machine-dependent microtime_getres(), maybe?



>Release-Note:
>Audit-Trail:
>Unformatted: