Mail Archives: djgpp/1998/03/03/20:38:33
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 -