Check this out:
http://oprofile.sourceforge.net/

This provides for hardware counter manipulation.

Karim

Chunky Kibbles wrote:
> 
> On Sat, Oct 20, 2001 at 12:20:17AM -0400, Christopher D. Carothers wrote:
> >       Gary -- use the "rdtsc" instruction which stands for read
> > timestamp counter. This instruction will return the number of cycles the
> > processor has been up since it was last rebooted. It is 64 bits so the
> > processor will turn to slag before it overflows.
> >
> >       Below is the inline assembly language that will compile under gcc.
> >
> > __inline__ unsigned long long int rdtsc()
> > {
> >   unsigned long long int x;
> >   __asm__ volatile (".byte 0x0f, 0x31" : "=A" (x));
> >   return x;
> > }
> >
> >       Note, that to get the seconds you need to divide by the speed of
> > the processor. Inside the kernel you can get the speed directly by using
> > the "cpu_khz" variable and multiple by 1000.0.
> >
> >       Final word, on SMP boxes each processor will have it own counter
> > register and because of clock drift (and slightly offset boot times) these
> > clocks will vary -- however, my experience is that for high-end/high-speed
> > systems this amount is not that noticeable -- but they will differ...
> >
> >               Hope that helps,
> >               Chris
> 
> Fabulous. I'm using it to find out exactly how long a given RT task
> takes by adding these bits to the schedulers.
> 
> But I also have to ask. There are other counters, there, that I've
> read about. There are 67 things that they can count, and they can do
> it at no cost to the system.
> 
> eg, cache hits&misses, cycles since counter was started, etc, etc.
> 
> I'm also interested in these as a more general thing. The number of
> ticks is all well and good, but I'd also like to know other stuff.
> 
> Thank-you very much,
> Gary (-;
> 
> PS It's getting added later today (=
> -- [rtl] ---
> To unsubscribe:
> echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
> echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
> --
> For more information on Real-Time Linux see:
> http://www.rtlinux.org/

-- 
===================================================
                 Karim Yaghmour
               [EMAIL PROTECTED]
      Embedded and Real-Time Linux Expert
===================================================
-- [rtl] ---
To unsubscribe:
echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
--
For more information on Real-Time Linux see:
http://www.rtlinux.org/

Reply via email to