Yes you appear to be correct about the emulation of rdtsc from within an
interrupt, it’s either absent or broken. If ClockCycles() wasn’t intended
to be interrupt safe on machines without a rdtsc instruction then a caveat
should be in the docs.
Yes, the Elan 520 has available other hardware times that I could read as my
timestamp. My times are all relative so that would work. I was trying not
to write any processor dependent code because the code will definitely be
moved to other non-Elan systems, but this is a relatively small thing and
it’s critical to the program’s function so…
Thank you for the comments.
“David Donohoe” <firstname.lastname@example.org> wrote in message
Jason Farque <> email@example.com> > wrote:
I’m using an AMD Elan 520 cpu and QNX RTP 6.1 and need to grab the
time of entry into a hardware interrupt. The ClockCycles() function
is not callable from within an interrupt so various sources have
inlining of the assembly to perform the task. Unfortunately, I cannot
for the thread that receives control from the interrupt to use
as the result is not consistent enough for our purposes.
I have downloaded this code:
for QNX4, but the included pragma included doesn’t seem to want to
and gives me an error under RTP 6.1:
(.text+0xf): undefined reference to ‘rdtsc64’
(where rdtsc64 is the pragma name)
Does anyone have an inline version of a RDTSC instruction working under
6.1 that they’d be willing to share?
There are three inline versions of rdtsc in /usr/include/x86/inline.h
for various compilers. However, using rdtsc is no better than calling
ClockCycles directly; look at the imlementation of ClockCycles in
/usr/include/x86/neutrino.h: it basically issues an rdtsc intruction.
On CPUs that do not have the rdtsc instruction, the kernal catches
it as an illegal instruction, and emulates it. This is why it blows
up in an interrupt handler on a CPU without the rdtsc intstruction:
illegal intstructions in a kernal or interrupt context tend to be bad.
It sounds like the docs are incorrect if they indicate that it is
safe to call ClockCycles() in an interrupt handler, either that or
it was supposed to work, but the rdtsc emulation in the kernel is broken.
I still haven’t solved your problem, but if you are only concerned
with a specific system (the AMD Elan one) you could figure out a way
to read a timestamp without using rdtsc; there may be some
timers/counters on the system that will do the trick.