How to detect if RDTSC returns a constant rate counter value?

后端 未结 4 1072
时光说笑
时光说笑 2021-01-19 15:17

It seems most newer CPUs from both AMD and Intel implement rdtsc as a constant rate counter, avoiding the issues caused by frequency changing as a result of things like Turb

4条回答
  •  南笙
    南笙 (楼主)
    2021-01-19 15:40

    You can use CPUID to tell you. From the docs on CPUID Fn8000_0007_EDX bit 8:

    TscInvariant: TSC invariant. The TSC rate is ensured to be invariant across all P-States, C-States, and stop grant transitions (such as STPCLK Throttling); therefore the TSC is suitable for use as a source of time. 0 = No such guarantee is made and software should avoid attempting to use the TSC as a source of time.

提交回复
热议问题