X-Recipient: archive-cygwin@delorie.com
X-Spam-Check-By: sourceware.org
X-YMail-OSG: YSHhIaQVM1la47lRNFJh7NV8VMPxEQeKdH5hc2phJ88CRAtLBqu0xxREPYBr_e.4he0TrCipML0UOA6CEjCkjM2Kt6ybkIIDhzH8ll.YAX38bL2a9A--
Message-ID: <471E9B41.6030205@computer.org>
Date: Tue, 23 Oct 2007 18:09:21 -0700
From: Tim Prince <tprince@computer.org>
User-Agent: Thunderbird 2.0.0.4 (X11/20070613)
MIME-Version: 1.0
To: cygwin@cygwin.com
Subject: Re: milliseconds on Windows
References: <38624.131.220.7.1.1193151578.squirrel@webmail.iai.uni-bonn.de> <Pine.CYG.4.58.0710231015060.3388@PC1163-8460-XP.flightsafety.com> <000201c81593$045ae260$02fea8c0@DDZG9K91>
In-Reply-To: <000201c81593$045ae260$02fea8c0@DDZG9K91>
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-IsSubscribed: yes
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com

Robert D. Holtz - Lists wrote:
>> Hello Brian,
> 
> http://cygwin.com/acronyms/#PPIOSPE
> 
> I've redirected this message and set the Reply-To appropriately.
> 
>> I'm a student at Bonn university and I'm researching robotics. I'm trying
>> to write a robot controller for Windows XP (wasn't my choice!) and
>> measuring elapsed time down to milliseconds precision is crucial. Do you
>> happen to remember this discussion on the cygwin mailing list?
>>

>> So if you know how to measure 1ms (less would be even better) on Win XP,
>> can you please tell me how to do that?
> 
> If you're feeling frisky it's also possible to write a low level routine
> that hooks the hardware clock and uses it for retrieving the time.
> 
> This clock does go down to microsecond granularity.
> 
As gcc hasn't implemented the Microsoft style __rdtsc() intrinsic, we
use routinely the usual gcc 32-bit-only stuff:

unsigned long long int rdtsc( )
{
   long long a;
   asm volatile("rdtsc":"=A" (a));
   return a;
}

which gives you a number of CPU clock ticks (on current platforms,
typically derived from the buss clock and nominal CPU clock speed ratio).

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

