News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

RDTSCP

Started by MichaelW, April 02, 2015, 09:23:28 AM

Previous topic - Next topic

MichaelW

I recently became aware of the RDTSCP instruction. There is an Intel whitepaper here that discusses its use in cycle-counting code. My Core i3, with two physical cores and no HTT, supports RDTSCP. Assuming that RDTSCP returns a processor or core ID, or similar, in ECX,  I thought it would be interesting to use it to monitor the processor core that my process is running on, to see if the system does move processes between cores, as I have seen some people claim it does.

I started out to do this as a 64-bit app coded in JWASM, but in the time I had to spend on it I could not find a good set of 64-bit header files, so I switched to Pelles C and POASM.

First surprise, RDTSCP seems to always return zero in ECX, independent of the process/thread affinity. Intel refers to the value in ECX as IA32_TSC_AUX,  and per this page, "the Linux kernel initializes this to the core's number, starting from zero." Also, on that same page, the "invariant TSC" stuff is interesting.
Well Microsoft, here's another nice mess you've gotten us into.

Gunther

Michael,

I have the Intel whitepaper since a long time in my Manual subdirectory and was therefore a bit surprised that you didn't know it. Anyway, here is the output on my machine:

1       255
1
4923796230654   0

2       255
1
4923797664386   0

        1
        4923798708896   0
        1
        4923798938477   0
        1
        4923799514661   0
        1
        4923799789527   0
        1
        4923799998476   0
        1
        4923800198509   0
        1
        4923800406335   0
        1
        4923800599097   0
        1
        4923800824230   0
        1
        4923801211339   0


        1
        4923806399764   0
        1
        4923806817468   0
        1
        4923808551438   0
        1
        4923810258996   0
        1
        4923812142019   0
        1
        4923871502647   0
        1
        4923874142743   0
        1
        4923876262351   0
        1
        4923879064898   0
        1
        4923881090506   0


Gunther
You have to know the facts before you can distort them.