TSC: Intro & Comments

Posted 三叁

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了TSC: Intro & Comments相关的知识,希望对你有一定的参考价值。

From wiki quote:

The Time Stamp Counter (TSC) is a 64-bit register present on all x86 processors since the Pentium. It counts the number of cycles since reset. The instruction RDTSC returns the TSC in EDX:EAX. In x86-64 mode, RDTSC also clears the higher 32 bits of RAX and RDX. Its opcode is 0F 31.[1] Pentium competitors such as the Cyrix 6x86 did not always have a TSC and may consider RDTSC an illegal instruction. Cyrix included a Time Stamp Counter in their MII.

The Time Stamp Counter was once an excellent high-resolution, low-overhead way for a program to get CPU timing information. With the advent of multi-core/hyper-threaded CPUs, systems with multiple CPUs, and hibernating operating systems, the TSC cannot be relied upon 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. Therefore, a program can get reliable results only by limiting itself to run on one specific CPU. Even then, the CPU speed may change because of power-saving measures taken by the OS or BIOS, or the system may be hibernated and later resumed, resetting the TSC. In those latter cases, to stay relevant, the program must re-calibrate the counter periodically.

Relying on the TSC also reduces portability, as other processors may not have a similar feature. Recent Intel processors include a constant rate TSC (identified by the kern.timecounter.invariant_tsc sysctl on FreeBSD or by the "constant_tsc" flag in Linux‘s /proc/cpuinfo). With these processors, the TSC ticks at the processor‘s nominal frequency, regardless of the actual CPU clock frequency due to turbo or power saving states. Hence TSC ticks are counting the passage of time, not the number of CPU clock cycles elapsed.

Starting with the Pentium Pro, Intel processors have practiced out-of-order execution, where instructions are not necessarily performed in the order they appear in the program. This can cause the processor to execute RDTSC later than a simple program expects, producing a misleading cycle count.[4] The programmer can solve this problem by inserting a serializing instruction, such as CPUID, to force every preceding instruction to complete before allowing the program to continue, or by using the RDTSCP instruction, which is a serializing variant of the RDTSC instruction.

And from here, if constant_tsc exist for cpu flag, TSC rate is the maximum CPU frequency.

Detailed kernel document about time-keeping is here.

A detailed intro is here.

And to note: constant_tsc + invariant_tsc = nonstop_tsc

 

以上是关于TSC: Intro & Comments的主要内容,如果未能解决你的问题,请参考以下文章

2016 - 1- 22 Build a Nav bar (intro to HTML&CSS)

2016 - 1- 22 img tag and the lists (intro to HMTL&CSS)

webpack 如何以及在哪里使用 tsconfig.file 和 tsc

Facebook Graph API event-id/comments?since=2014-02-01&until=2014-02-10 ,日期过滤器无效

722. Remove Comments

Rails - 在当前页面链接到Div