delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2007/02/12/16:18:21

X-Spam-Check-By: sourceware.org
To: cygwin AT cygwin DOT com
From: "Cary Jamison" <Cary_Jamison AT Symantec DOT com>
Subject: Re: strange bug in gettimeofday function
Date: Mon, 12 Feb 2007 14:17:26 -0700
Lines: 30
Message-ID: <eqqlha$eoe$1@sea.gmane.org>
References: <1562006224 DOT 20070211192014 AT gnu DOT org>
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
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.
>>
>> 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.

Is this a dual-core AMD perchance?

There are some high-performance timing instructions that can get off between 
the two cores.  I wouldn't think that gettimeofday would use these, but 
maybe?

Let's see, it looks like the RDTSC instruction, or the Windows 
QueryPerformanceCounter().  This problem doesn't occur on Intel multi-cores. 
It is caused by AMD attempting to save power by throttling the cores back 
separately.  You can google for lots of information about the pros/cons of 
different patches by Microsoft and AMD to resolve the problem.

I don't have the cygwin source to check if these are used anywhere.


Cary




--
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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019