TSC(9) | Kernel Developer's Manual (x86) | TSC(9) |
uint64_t
rdtsc(void);
void
tsc_tc_init(void);
void
tsc_sync_ap(struct cpu_info *ci);
void
tsc_sync_bp(struct cpu_info *ci);
void
tsc_sync_drift(int64_t drift);
Already because of the access method, TSC has traditionally provided a low-overhead and high-resolution way to obtain CPU timing information. Recently, however, this reliability has been undermined by such factors as system sleep states, CPU “hotplugging”, “hibernation”, and CPU frequency scaling.
These potential new sources of unreliability are easily understandable when one recalls that the counter measures cycles and not “time”. Comparing the cycle counts only makes sense when the clock frequency is stable; to convert the cycle counts to time units, a general equation would be: “seconds = cycles / frequency in Hz”. The use of TSC as a source of high-resolution timing can be thus discouraged. But the basic premise is still guaranteed: TSC is a monotonically increasing counter.
It is necessary to call both tsc_sync_ap() and tsc_sync_bp() during the boot, but additional synchronization may be required also during runtime. As an example, the TSC needs to be synchronized for all processors when the system resumes from an acpi(4) sleep state.
October 25, 2011 | NetBSD 6.1 |