I am sending network packets from one thread and receiving replies on a 2nd thread that runs on a different CPU core. My process measures the time between send & receive of each packet (similar to ping). I am using rdtsc for getting high-resolution, low-overhead timing, which is needed by my implementation.
All measurments looks reliable. Still, I am worried about rdtsc accuracy across cores, since I’ve been reading some texts which implied that tsc is not synced between cores.
I found the following info about TSC in wikipedia
Constant TSC behavior ensures that the duration of each clock tick is
uniform and supports the use of the
TSC as a wall clock timer even if the
processor core changes frequency. This
is the architectural behavior moving
forward for all Intel processors.
Still I am worried about accruracy across cores, and this is my question
More Info
- I run my process on an Intel nehalem machine.
- Operating System is Linux.
- The “constant_tsc” cpu flag is set for all the cores.
X86_FEATURE_CONSTANT_TSC+X86_FEATURE_NONSTOP_TSCbits in cpuid (edx=x80000007, bit #8; checkunsynchronized_tscfunction of linux kernel for more checks)Intel’s Designer’s vol3b, section 16.11.1 Invariant TSC it says the following
So, if TSC can be used for wallclock, they are guaranteed to be in sync.