From owner-freebsd-hackers Fri Jan 21 0:28:43 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from resnet.uoregon.edu (resnet.uoregon.edu [128.223.144.32]) by hub.freebsd.org (Postfix) with ESMTP id 8C971151CF for ; Fri, 21 Jan 2000 00:28:41 -0800 (PST) (envelope-from dwhite@resnet.uoregon.edu) Received: from localhost (dwhite@localhost) by resnet.uoregon.edu (8.9.3/8.9.3) with ESMTP id AAA54572; Fri, 21 Jan 2000 00:28:40 -0800 (PST) (envelope-from dwhite@resnet.uoregon.edu) Date: Fri, 21 Jan 2000 00:28:40 -0800 (PST) From: Doug White To: Sabrina Minshall Cc: hackers@FreeBSD.ORG Subject: Re: PR kern/14034: gettimeofday() returns negative value? In-Reply-To: <200001200141.RAA30336@shell.accesscom.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Wed, 19 Jan 2000, Sabrina Minshall wrote: > What's going one here? Successive calls to gettimeofday > yields negative elapsed time? I'm sorry, but this is plain bad math. If the samples t1 and t2 were taken in that order from a monotonically increasing value, then > s = t1->tv_sec - t2->tv_sec; > assert((s >= 0)); and > ms = s * 1000000 + (t1->tv_usec - t2->tv_usec); will never be positive. If t2 >= t1, then t1 - t2 <= 0. If time was truly moving backwards on your system, then your assertion would succeed instead of fail. I think you will find everything is working properly if you reverse the arguments to time_elapsed(). Doug White | FreeBSD: The Power to Serve dwhite@resnet.uoregon.edu | www.FreeBSD.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message