delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/03/03/20:38:33

Date: Tue, 3 Mar 1998 17:37:44 -0800 (PST)
Message-Id: <199803040137.RAA07815@adit.ap.net>
Mime-Version: 1.0
To: "Andris Pavenis" <pavenis AT acad DOT latnet DOT lv>, djgpp AT delorie DOT com
From: Nate Eldredge <eldredge AT ap DOT net>
Subject: Re: A question about DJGPP's clock?()

At 05:35  3/3/1998 -0600, Andris Pavenis wrote:
>If You really don't nead portability and You using PENTIUM OR BETTER
>CPU then why not to use Pentium timestamp counter. It is very easy to
>read it.
[snipped]
>should get time in variable A; Note that timestamp counter counts
>CPU clocks so You need to divide result with CPU clock frequency to
>get seconds.

But beware that finding the clock frequency through software is a difficult
task! It's fine if you're only going to use it on your own machine, but
otherwise, it may not be worth it.

> This code should work also under Linux.

If I'm correct, RDTSC is a privileged instruction, so it may give a fatal
signal instead. I think the system can set a bit in a control register to
allow user programs to use the TSC, but I don't know whether Linux does.
Have you tried it? (I would, but I don't have a Pentium.)

Nate Eldredge
eldredge AT ap DOT net



- Raw text -


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