X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f From: RayeR Newsgroups: comp.os.msdos.djgpp Subject: bad delay() precision on intel C2D machine under pure DOS Date: Wed, 2 Apr 2008 09:00:06 -0700 (PDT) Organization: http://groups.google.com Lines: 25 Message-ID: <2ec27f4c-d3e0-40e6-b8b8-90661858a522@u36g2000prf.googlegroups.com> NNTP-Posting-Host: 89.176.208.108 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1207152006 22748 127.0.0.1 (2 Apr 2008 16:00:06 GMT) X-Complaints-To: groups-abuse AT google DOT com NNTP-Posting-Date: Wed, 2 Apr 2008 16:00:06 +0000 (UTC) Complaints-To: groups-abuse AT google DOT com Injection-Info: u36g2000prf.googlegroups.com; posting-host=89.176.208.108; posting-account=Q0wMHAoAAADjYrghh94FTf6YnbpTqZgp User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.8.1.12) Gecko/20080201 SeaMonkey/1.1.8,gzip(gfe),gzip(gfe) X-Original-Bytes: 2200 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com In my CPUID utility I measure CPU frequency via TSC using delay as a time base, code looks like this tsc=rdtsc(); // precti time stamp counter z CPU delay(500); // pockej chvilku tsc=rdtsc()-tsc; // precti time stamp counter z CPU a spocti rozdil But I found on faster machine intel C2D it takes longer time than should. Same for pure DOS and Win9x dos box. Then I found it helps when I split one delay to two or more delay calls: tsc=rdtsc(); // precti time stamp counter z CPU delay(250); // pockej chvilku (kvuli nejake chybe v DJGPP je nutno rozlozit delay(250); // pockej chvilku tsc=rdtsc()-tsc; // precti time stamp counter z CPU a spocti rozdil Then it seems to be OK but why? I also tried my udelay() function based on uclock() which has perfect precision in pure DOS but it's shorter in win9x. I use DJGPP 2.04, I know that delay code was changed but hoped it doesn't affect DOS.