From marcelk@bitpit.net Sun Jun 20 06:52:35 1999
Return-Path: <marcelk@bitpit.net>
Received: from unox.student.tue.nl (unox.student.tue.nl [131.155.210.3])
	by hub.freebsd.org (Postfix) with ESMTP id 5F92514D54
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 20 Jun 1999 06:52:31 -0700 (PDT)
	(envelope-from marcelk@bitpit.net)
Received: from brick.bitpit.net (brick.bitpit.net [192.168.0.6]) by unox.student.tue.nl (8.9.1/8.8.8) with ESMTP id PAA27471 for <FreeBSD-gnats-submit@freebsd.org>; Sun, 20 Jun 1999 15:52:29 +0200
Received: (from marcelk@localhost) by brick.bitpit.net (8.9.3/8.8.3) id PAA53936; Sun, 20 Jun 1999 15:52:29 +0200 (CEST)
Message-Id: <199906201352.PAA53936@brick.bitpit.net>
Date: Sun, 20 Jun 1999 15:52:29 +0200 (CEST)
From: marcelk@bitpit.net
Reply-To: marcelk@bitpit.net
To: FreeBSD-gnats-submit@freebsd.org
Subject: clock() ticks backwards
X-Send-Pr-Version: 3.2

>Number:         12305
>Category:       kern
>Synopsis:       clock() ticks backwards
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Jun 20 07:00:02 PDT 1999
>Closed-Date:    Fri Jul 20 15:59:06 PDT 2001
>Last-Modified:  Fri Jul 20 15:59:56 PDT 2001
>Originator:     Marcel van Kervinck
>Release:        FreeBSD 3.2-BETA i386
>Organization:
>Environment:

Observed in releases 2.2, 3.1 and 3.2, SMP and non-SMP kernels.

>Description:

Consecutive calls to clock() sometimes suggest negative elapsed time.

>How-To-Repeat:

#include <time.h>
#include <stdio.h>

int main (void)
{
	clock_t a, b;

	for (;;) {
		b = clock ();
		do {
			a = b;
			b = clock ();
		} while (a <= b);

		printf ("%lu %lu\n", (unsigned long)a, (unsigned long)b);
	}
	return 0;
}


>Fix:
>Release-Note:
>Audit-Trail:

From: Bruce Evans <bde@zeta.org.au>
To: FreeBSD-gnats-submit@FreeBSD.ORG, marcelk@bitpit.net
Cc:  
Subject: Re: kern/12305: clock() ticks backwards
Date: Mon, 21 Jun 1999 10:45:38 +1000

 >>Description:
 >
 >Consecutive calls to clock() sometimes suggest negative elapsed time.
 
 This is probably fixed in -current:
 
 ---
 bde         1999/03/13 11:46:13 PST
 
   Modified files:
     sys/kern             kern_resource.c 
     sys/sys              resourcevar.h 
   Log:
   Enforce monotonicity of apparent process user, system and interrupt times.
   
   PR:		975, 10402
   
   Revision  Changes    Path
   1.45      +51 -22    src/sys/kern/kern_resource.c
   1.13      +4 -1      src/sys/sys/resourcevar.h
 ---
 
 clock() could reduce this problem by adding the user and system times.
 This would also increase its precision from about 16000 usec to about
 8000 usec.  It discards about about 8000 usec of precision for historical
 reasons.  (clock_t should be double so that CLOCKS_PER_SECOND can be
 10^6 or 10^9.)
 
 Bruce
 
State-Changed-From-To: open->closed 
State-Changed-By: mike 
State-Changed-When: Fri Jul 20 15:59:06 PDT 2001 
State-Changed-Why:  

As per the Audit-Trail, bde believes this was corrected. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=12305 
>Unformatted:
