From owner-freebsd-bugs Mon Aug 19 8:30:10 2002 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4D16C37B400 for ; Mon, 19 Aug 2002 08:30:03 -0700 (PDT) Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9BD9E43E4A for ; Mon, 19 Aug 2002 08:30:02 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.4/8.12.4) with ESMTP id g7JFU2JU068610 for ; Mon, 19 Aug 2002 08:30:02 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.4/8.12.4/Submit) id g7JFU2KO068609; Mon, 19 Aug 2002 08:30:02 -0700 (PDT) Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9EF9137B400 for ; Mon, 19 Aug 2002 08:29:20 -0700 (PDT) Received: from www.freebsd.org (www.FreeBSD.org [216.136.204.117]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6140E43E6A for ; Mon, 19 Aug 2002 08:29:20 -0700 (PDT) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.12.4/8.12.4) with ESMTP id g7JFTKOT066377 for ; Mon, 19 Aug 2002 08:29:20 -0700 (PDT) (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.12.4/8.12.4/Submit) id g7JFTKSe066376; Mon, 19 Aug 2002 08:29:20 -0700 (PDT) Message-Id: <200208191529.g7JFTKSe066376@www.freebsd.org> Date: Mon, 19 Aug 2002 08:29:20 -0700 (PDT) From: Kevin Martin To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-1.0 Subject: kern/41781: clock_getres returns tv_nsec=0 when TSC is 1Ghz or faster Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >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 #include 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