www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2003/02/11/09:45:15

From: "Ben Peddell" <lightspeed85 AT hotmail DOT com>
Newsgroups: comp.os.msdos.djgpp
References: <Pine DOT SUN DOT 3 DOT 91 DOT 1030210075002 DOT 7932C AT is> <b29tp3$1agvkq$1 AT ID-79865 DOT news DOT dfncis DOT de> <3e489301 DOT sandmann AT clio DOT rice DOT edu> <%v22a.45175$jM5 DOT 113869 AT newsfeeds DOT bigpond DOT com> <3E48F219 DOT 8FB9B40B AT yahoo DOT com>
Subject: Re: how to make a Timer
Lines: 28
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2615.200
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200
Message-ID: <dP72a.45469$jM5.114036@newsfeeds.bigpond.com>
Date: Wed, 12 Feb 2003 00:42:17 +1000
NNTP-Posting-Host: 144.139.175.230
X-Trace: newsfeeds.bigpond.com 1044973897 144.139.175.230 (Wed, 12 Feb 2003 01:31:37 EST)
NNTP-Posting-Date: Wed, 12 Feb 2003 01:31:37 EST
Organization: Telstra BigPond Internet Services (http://www.bigpond.com)
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

>
> Please do not toppost.  RDTSC will cause a bad opcode trap on a
> 486, or a 386, both of which are suitable processors for the DJGPP
> system.  Bad idea.
>

My idea is that the uclock() checks whether rdtsc is available when it is
first called. And, if it's available the use it. If it's not, don't.
First, check the existence of cpuid. If it does not exist, then the tsc does
not exist, so go to the normal pit routine. If cpuid does exist, then use it
to determine the existence of the tsc. If it does not exist, then go to the
normal pit routine. If the tsc does exist, then check for the existence of
cr4. If it exists, then check the setting of the tsd (Time Stamp Disable)
bit (bit 2). If it is set, then go to the normal pit routine, as the tsc has
been disabled for all but cpl=0. If the tsc has not been disabled, then time
the cpu to determine the ratio between the cpu speed and the pit speed,
store that ratio in a global variable, and set a flag signalling that rdtsc
is available.
Then, on each subsequent call of uclock(), it can either read the tsc and
divide by the cpu/pit ratio, or get the standard pit + bios time, depending
on the "rdtsc available" flag.
Now, the only case when the tsc would be unavailable under Windows XP would
be when WinXP specifically disables access to the tsc, as Windows XP will
only run on a Pentium class or better cpu. (Do you know of any 486's that
run at 233MHz?)



- Raw text -


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