最後更新: 2023-12-27
介紹
hpet = High Precision Timer
Linux Default: TSC(Time Stamp Counter)
Enable & Use hpet
* hpet need to enable in the BIOS
# Check if HPET is enabled
# timer_list: include both hardware and software timers
grep ^Clock /proc/timer_list
Clock Event Device: hpet Clock Event Device: lapic Clock Event Device: lapic
# If the HPET is to be used
ls -l /dev/hpet
crw------- 1 root root 10, 228 Nov 6 14:48 /dev/hpet
# Checking the current clock source
cat /sys/devices/system/clocksource/clocksource0/current_clocksource
tsc
# available clock sources
cat /sys/devices/system/clocksource/*/available_clocksource
tsc hpet acpi_pm
Settings
temporarily
echo "acpi_pm" > /sys/devices/system/clocksource/clocksource0/current_clocksource
kernel-parameters([X86-64] hpet,tsc)
clocksource=hpet # Override the default clocksource
Hardware clock
Time Stamp Counter (TSC)
- the clock ticks at 1 GHz
- All 80x86 microprocessors include a CLK input pin, which receives the clock signal of an external oscillator.
- It is accessible through the TSC register which can be read by means of the rdtsc assembly instruction.
High Precision Event Timer (HPET)
- Basically the chip includes up to eight 32 bit or 64 bit independent counters.
- Each counter is driven by its own clock signal, whose frequency must be at least 10 MHz.
- The HPET registers allow the kernel to read and write the values of the counters and of the match registers, to program one-shot interrupts
ACPI Power Management Timer (ACPI PMT)
- included in almost all ACPI-based motherboards.
- a fixed frequency of roughly 3.58 MHz.
- May introduce issues with sub-millisecond resolution. (clock source of last resort only)