Hacker News new | ask | show | jobs
by elteto 350 days ago
How does rdtsc behave in the presence of multiple cores? As in: first time sample is taken on core P, process is pre-empted, then picked up again by core Q, second time sample is taken on core Q. Assume x64 Intel/AMD etc.
1 comments

In trading all threads are pinned to a core, so that scenario doesn't happen.
Yeap!

Also - all modern systems in active use have invariant tsc. So even for migrating threads - one is ok.

You could still have a receiving thread and a sending thread for example, so it’s not as simple.

But googling suggests that if the CPU has the invariant_tsc flag then it’s not a problem, as foobar mentions.