X-Spam-Check-By: sourceware.org Message-ID: <45CFD856.10106@gmail.com> Date: Mon, 12 Feb 2007 11:00:38 +0800 From: Carlo Florendo User-Agent: Thunderbird 1.5.0.9 (Windows/20061207) MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: Re: strange bug in gettimeofday function References: <1562006224 DOT 20070211192014 AT gnu DOT org> In-Reply-To: <1562006224.20070211192014@gnu.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Andrew Makhorin wrote: > Hi, > > I detected a strange bug in the standard function gettimeofday. > It *sometimes* reports the time which being expressed as the integer > number of milliseconds is *less* than the time obtained *earlier* with > the same function. If you mean that you call gettimeofday twice and you get different values at each call, with a difference of about 100 ms, then this is all right. Read on... > > The expression 1000000 * tv.tv_sec + tv.tv_usec is calculated in > 64-bit arithmetic, so overflow cannot happen. The negative difference > in the time values on two successive calls is about 100 milliseconds. Please keep in mind that windows is a pre-emptive multi-tasking OS. This means that there is a lot of time-sharing among multiple processes. Windows could be accurate up to 15 ms or perhaps a little bit more. However, it is very difficult to achieve less than 15 ms or microsecond accuracy with windows due to the limitation on the OS itself. Our extensive tests on windows clocks and timers reveal that windows cannot be accurate to the microsecond level or below 15 ms. FWIW, The accuracy of gettimeofday may also depend on the processor speed. In any case, in my experience, windows cannot be accurate with a precision of up to 15 milliseconds. The time difference you are seeing seems normal to me (unless I have not understood you correctly, in which case, I apologize in advance.) Thank you very much. Best Regards, Carlo -- Carlo Florendo Softare Engineer/Network Co-Administrator Astra Philippines Inc. UP-Ayala Technopark, Diliman 1101, Quezon City Philippines http://www.astra.ph Member of the Astra Group of Companies 5-3-11 Sekido, Tama City Tokyo 206-0011, Japan http://www.astra.co.jp -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/