delorie.com/archives/browse.cgi | search |
From: | "Tom St Denis" <tomstdenis AT yahoo DOT com> |
Newsgroups: | comp.os.msdos.djgpp |
References: | <3ACABB23 AT MailAndNews DOT com> |
Subject: | Re: Any comments about using RDTSC to sync code ? |
Lines: | 47 |
X-Priority: | 3 |
X-MSMail-Priority: | Normal |
X-Newsreader: | Microsoft Outlook Express 5.50.4522.1200 |
X-MimeOLE: | Produced By Microsoft MimeOLE V5.50.4522.1200 |
Message-ID: | <O1zx6.177142$p66.52247228@news3.rdc1.on.home.com> |
Date: | Sun, 01 Apr 2001 05:30:22 GMT |
NNTP-Posting-Host: | 24.112.8.23 |
X-Complaints-To: | abuse AT home DOT net |
X-Trace: | news3.rdc1.on.home.com 986103022 24.112.8.23 (Sat, 31 Mar 2001 21:30:22 PST) |
NNTP-Posting-Date: | Sat, 31 Mar 2001 21:30:22 PST |
Organization: | Excite AT Home - The Leader in Broadband http://home.com/faster |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
Reply-To: | djgpp AT delorie DOT com |
"Eduardo TUDA Lorenzetti Pellini" <dochell AT MailAndNews DOT com> wrote in message news:3ACABB23 AT MailAndNews DOT com... > Hi DJGPP friends, > > I'm doing a real time app using DJGPP that runs for almost 2 hours polling > and > reading some hardware ports in loops of 50 usec (*micro*seconds). > I'm using the Pentium TSC counter to sync the data acquision since the RTC > and > system timer don't have this desired resolution or have some undesired > granularity. > > The first problem i am living is to accurately calculate the CPU clock to > stablish the relationship between system clocks and real time. > > The second problem is that (i think) PC hardware don't have any > stabilization > method for the CPU internal clock (Xtal voltage and temperature regulation). > So i think that the CPU clock may vary, but i don't know how much. Typically it's about 10%. My athlon 1200mhz runs at "supposedly" 1211mhz according to various programs. > The third problem is about the TSC reading routine (RDTSC) and the 64 bits > arithmetic involved to calculate the elapsed time. They impact on the CPU, > but > i don't know how much. On a Pentium 100 system I estimated that RDTSC takes > from 12 to 24 clocks to finnish. And about the 64 bits arithmetic ? DJGPP > supports it, but i don't think that the operations are somehow hardware > accelerated. Am i right ? Are there any WWX (the oposite of MMX 8) > instructions on any Intel/AMD class processor that could be used by DJGPP or > inline assembler ? Well you can do 64-bit math on an x86 several ways. The x86 set does have "add/sub" with carries so you can add a 64-bit word in two cycles. You can multiply one in about 10 or so... etc.. Using RDTSC to sync programs is a bad idea since RDTSC may take a variable amount of cycles to complete. Tom
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |