Date: Fri, 21 Jan 2000 00:28:40 -0800 (PST) From: Doug White <dwhite@resnet.uoregon.edu> To: Sabrina Minshall <sabrina@accesscom.com> Cc: hackers@FreeBSD.ORG Subject: Re: PR kern/14034: gettimeofday() returns negative value? Message-ID: <Pine.BSF.4.21.0001210017590.51684-100000@resnet.uoregon.edu> In-Reply-To: <200001200141.RAA30336@shell.accesscom.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0001210017590.51684-100000>