同一篇WikiPedia文章确实提到了 TSC 的问题,如下所示,
With the advent of multi-core/hyper-threaded CPUs, systems with multiple CPUs, and
hibernating operating systems, the TSC cannot be relied on to provide accurate results
— unless great care is taken to correct the possible flaws: rate of tick and whether
all cores (processors) have identical values in their time-keeping registers. **There
is no promise that the timestamp counters of multiple CPUs on a single motherboard will
be synchronized**. In such cases, programmers can only get reliable results by locking
their code to a single CPU. Even then, the CPU speed may change due to power-saving
measures taken by the OS or BIOS, or the system may be hibernated and later resumed
(resetting the time stamp counter). In those latter cases, to stay relevant, the
counter must be recalibrated periodically (according to the time resolution your
application requires).
这意味着现代 CPU 可以更改其 CPU 时钟频率以节省可能影响 TSC 值的功率。此外,TSC 永远不会在诸如内核可能执行 HALT 并停止处理器直到接收到外部中断的情况下增加。
the second question is that i have intel xeon i3 processor which has 4 processors &
each having 2 cores then measuring the clock ticks will give the ticks of single
processor or addition of all 4 processors..?
这可能会导致进程可以在一个处理器上读取时间,移动到第二个处理器并遇到比它在第一个处理器上读取的时间更早的时间,从而导致 TSC 成为不稳定的时间源。