High Precision Event Timer
Encyclopedia
The High Precision Event Timer is a hardware
timer used in personal computers. It was developed jointly by Intel and Microsoft
and has been incorporated in PC chipsets since circa 2005. Formerly referred to by Intel as a Multimedia Timer, the term HPET was selected to avoid confusion with the multimedia timers
software feature introduced in the MultiMedia Extensions to Windows 3.0
.
Older operating systems do not support HPET and can only use older timing facilities, such as the programmable interval timer
or the real-time clock
.
(main counter) counting at least at 10 MHz and a set of up to 256 comparators (at least 3). These comparators are 32- or 64-bit wide. The HPET is programmed via a memory mapped I/O window that is discoverable via ACPI
. The HPET circuit in modern PCs is integrated into the southbridge chip
.On these highly integrated dies the BIOS
often sets up the HPET incorrectly in the ACPI, initializing it correctly only in Intel 8253
mode. If the ACPI is not set up correctly the OS
cannot list the HPET. And the BIOS and OS developers don't see the need to get Real Time support. So the HPET is only there to satisfy the systems high speed needs. If the HPET is set up correctly in the ACPI from BIOS then the ACPI MMIO page of the first HPET chip should be at 0xFED00000 and the second HPET at page 0xFED80000 (see the discussion for further information).
Each comparator can generate an interrupt
when the least significant bits are equal to the corresponding bits of the 64-bit main counter value. The comparators can be put into one-shot mode or periodic mode, with at least one comparator supporting periodic mode and all of them supporting one-shot mode. In one-shot mode the comparator fires an interrupt once when the main counter reaches the value stored in the comparator's register, while in the periodic mode the interrupts are generated at specified intervals.
Comparators can be driven by the operating system, e.g. to provide one timer per CPU for scheduling, or by applications.
While 8254 and RTC can, similarly to HPET, be put in one-shot mode, the set-up process is so slow that their one-shot mode is not used in practice for tasks requiring precise scheduling. Instead, 8254 and RTC are typically used in periodic mode with very small time interval. For example, if an application needs to perform several short (some milliseconds, perhaps) waits, it is better to have a periodic timer running constantly with 1 ms period because of the high setup cost of an 8254 or RTC one-shot timer. This causes an interrupt on every millisecond even if the application needs to do actual work less frequently. With HPET, the extra interrupts can be avoided, because the set-up cost of a HPET one-shot timer is considerably smaller.
The following operating systems are known not to be able to use HPET:
Windows XP
,Windows XP
, SP2 knows the HPET timer (as a device with PNP0103 identifier). When detected (for example, on Intel DQ45CB motherboard), Device Manager (START / SETTINGS / CONTROL_PANEL / SYSTEM / DEVICE_MANAGER) shows "High Precision Event Timer" device in "System devices" branch. But this device has no driver and is not used at all. Windows Server 2003
, and earlier Windows
versions, Linux
kernels prior to 2.6.With a Linux kernel
, you need the newer "rtc-cmos" hardware clock device driver rather than the original "rtc" driver.
The following operating systems are known to be able to use HPET:
Windows XP
,On XP SP3 the IRQ0 and IRQ8 are often both mapped to a "High Precision Event Timer" when using the ACPI HAL (version 5.1.2600.5512), albeit that the QueryPerformanceFrequency API call returns a value related to the rated processor clock speed (e.g. 2.6GHz) rather than the Intel HPET spec'd value of 15MHz that you would get using Vista. This anomaly muddies the water about what is meant by "HPET" on such systems, but it is clearly not the 15MHz Intel device in those cases. On any system, the quoted frequency has to be stable in order to qualify for QueryPerformanceFrequency, so the quoted CPU-based clock speed is clearly not an ongoing reading of the CPU core frequency itself. However, its high value implicates the TSC (Time Stamp Counter) mechanism as being the basis of this apparent "HPET". Note that this IRQ mapping and clock relationship can be found both on Intel systems and AMD systems that are not using the /USEPMTIMER boot override. There can be concerns over the stability of the TSC-derived QueryPerformanceCounter readings on multicore systems as the actual frequency (i.e. not the reported frequency) may vary. Whilst the most recent ACPI HAL apparently includes code to synchronize the counters between processors, it is not entirely clear how it deals with variations in frequency under power management or the deliberate clock dither (spread-spectrum settings) that can be set in the BIOS.
On both Intel and AMD machines using the ACPI HAL together with the /USEPMTIMER boot switch, the IRQs 0 & 8 will still report a HPET, but now the QueryPerformanceFrequency will report 3.579545MHz, which is the frequency of the PMTIMER. This has the express advantage of being independent of the CPU frequency and still provides a very reasonable sub-microscecond resolution and accuracy.
With or without the /PMTIMER switch, the "event" part of the HPET specification can only be emulated, since neither underlying solution includes implicit hardware for aperiodic event triggering as described by the specification, and yet this is available via the timer API in XP (to a best possible resolution of 0.9766ms). This part of the specification is most probably still fulfilled by the RTC or similar device with the help of software, despite the fact that the device manager is quoting HPET in the IRQ0 and IRQ8 positions.
So it appears that the term "High Precision Event Timer" was already being used to describe TSC (Time-Stamp-Counter) and PMTimer systems before the 15MHz Intel HPET came into being. So whilst it is true to say that only Vista and later Windows use the Intel 15MHz HPET, the terminology of HPET exists for Windows XP, albeit to a different specification and reduced capability. In short, XP SP3 "emulates" most of the HPET specification (drafted in 2002) in anticipation of a device that made its eventual appearance in PCs designed for Windows Vista by 2005. Windows 2008, Windows Vista
, Windows 7, x86 based versions of Mac OS X
, Linux
operating systems using the 2.6 kernel, FreeBSD
and OpenSolaris
.
s (such as System Management Interrupts
) that do not have a hard upper bound on their execution time, this race condition
requires time-consuming re-checks of the timer after setup and is hard to avoid completely. The difficulties are exacerbated if the comparator value is not synchronized with the timer immediately, but delayed by one or two ticks, as some chipsets do.
Computer hardware
Personal computer hardware are component devices which are typically installed into or peripheral to a computer case to create a personal computer upon which system software is installed including a firmware interface such as a BIOS and an operating system which supports application software that...
timer used in personal computers. It was developed jointly by Intel and Microsoft
Microsoft
Microsoft Corporation is an American public multinational corporation headquartered in Redmond, Washington, USA that develops, manufactures, licenses, and supports a wide range of products and services predominantly related to computing through its various product divisions...
and has been incorporated in PC chipsets since circa 2005. Formerly referred to by Intel as a Multimedia Timer, the term HPET was selected to avoid confusion with the multimedia timers
Multimedia Timers
MultiMedia Timers is a term used by Microsoft in reference to high resolution timers accessible in systems using Windows 95 and later versions. The range of resolutions is described as system specific, but most systems that can run Windows 95 or later versions will support a minimum timer period...
software feature introduced in the MultiMedia Extensions to Windows 3.0
Windows 3.0
Windows 3.0, a graphical environment, is the third major release of Microsoft Windows, and was released on 22 May 1990. It became the first widely successful version of Windows and a rival to Apple Macintosh and the Commodore Amiga on the GUI front...
.
Older operating systems do not support HPET and can only use older timing facilities, such as the programmable interval timer
Programmable Interval Timer
In computing and in embedded systems, a programmable interval timer is a counter which triggers an interrupt when it reaches the programmed count.- Common features :...
or the real-time clock
Real-time clock
A real-time clock is a computer clock that keeps track of the current time. Although the term often refers to the devices in personal computers, servers and embedded systems, RTCs are present in almost any electronic device which needs to keep accurate time.-Terminology:The term is used to avoid...
.
Features
An HPET chip consists of a 64-bit up-counterCounter
In digital logic and computing, a counter is a device which stores the number of times a particular event or process has occurred, often in relationship to a clock signal.- Electronic counters :...
(main counter) counting at least at 10 MHz and a set of up to 256 comparators (at least 3). These comparators are 32- or 64-bit wide. The HPET is programmed via a memory mapped I/O window that is discoverable via ACPI
Advanced Configuration and Power Interface
In computing, the Advanced Configuration and Power Interface specification provides an open standard for device configuration and power management by the operating system....
. The HPET circuit in modern PCs is integrated into the southbridge chip
Southbridge (computing)
The southbridge is one of the two chips in the core logic chipset on a personal computer motherboard, the other being the northbridge. The southbridge typically implements the slower capabilities of the motherboard in a northbridge/southbridge chipset computer architecture. In Intel chipset...
.On these highly integrated dies the BIOS
BIOS
In IBM PC compatible computers, the basic input/output system , also known as the System BIOS or ROM BIOS , is a de facto standard defining a firmware interface....
often sets up the HPET incorrectly in the ACPI, initializing it correctly only in Intel 8253
Intel 8253
The Intel 8253 and 8254 are Programmable Interval Timers , which perform timing and counting functions. They were primarily designed for the Intel 8080/8085-processors, but later used in x86-systems...
mode. If the ACPI is not set up correctly the OS
OS
OS may refer to:* O.S. Old Stonyhurst, an old boy of the ancient Jesuit public school, Stonyhurst College* O.S. Engines, a Japanese manufacturer of model aircraft engines* Ocean Science, an Oceanographic Journal published by the European Geosciences Union....
cannot list the HPET. And the BIOS and OS developers don't see the need to get Real Time support. So the HPET is only there to satisfy the systems high speed needs. If the HPET is set up correctly in the ACPI from BIOS then the ACPI MMIO page of the first HPET chip should be at 0xFED00000 and the second HPET at page 0xFED80000 (see the discussion for further information).
Each comparator can generate an interrupt
Interrupt
In computing, an interrupt is an asynchronous signal indicating the need for attention or a synchronous event in software indicating the need for a change in execution....
when the least significant bits are equal to the corresponding bits of the 64-bit main counter value. The comparators can be put into one-shot mode or periodic mode, with at least one comparator supporting periodic mode and all of them supporting one-shot mode. In one-shot mode the comparator fires an interrupt once when the main counter reaches the value stored in the comparator's register, while in the periodic mode the interrupts are generated at specified intervals.
Comparators can be driven by the operating system, e.g. to provide one timer per CPU for scheduling, or by applications.
Applications
The HPET can produce periodic interrupts at a much higher resolution than the RTC and is often used to synchronize multimedia streams, providing smooth playback and reducing the need to use other timestamp calculations such as an X86-based CPU's RDTSC instruction.Comparison to predecessors
HPET is meant to supplement and replace the 8254 programmable interval timer and the RTC's periodic interrupt function. Compared to these older timer circuits, the HPET has higher frequency (at least 10 MHz) and wider 64-bit counters (although they can be driven in 32-bit mode).While 8254 and RTC can, similarly to HPET, be put in one-shot mode, the set-up process is so slow that their one-shot mode is not used in practice for tasks requiring precise scheduling. Instead, 8254 and RTC are typically used in periodic mode with very small time interval. For example, if an application needs to perform several short (some milliseconds, perhaps) waits, it is better to have a periodic timer running constantly with 1 ms period because of the high setup cost of an 8254 or RTC one-shot timer. This causes an interrupt on every millisecond even if the application needs to do actual work less frequently. With HPET, the extra interrupts can be avoided, because the set-up cost of a HPET one-shot timer is considerably smaller.
Compatibility
Operating systems designed before HPET existed cannot use HPET, so work only on hardware that has other timer facilities. Newer operating systems tend to be able to use either. Some hardware has both.The following operating systems are known not to be able to use HPET:
Windows XP
Windows XP
Windows XP is an operating system produced by Microsoft for use on personal computers, including home and business desktops, laptops and media centers. First released to computer manufacturers on August 24, 2001, it is the second most popular version of Windows, based on installed user base...
,Windows XP
Windows XP
Windows XP is an operating system produced by Microsoft for use on personal computers, including home and business desktops, laptops and media centers. First released to computer manufacturers on August 24, 2001, it is the second most popular version of Windows, based on installed user base...
, SP2 knows the HPET timer (as a device with PNP0103 identifier). When detected (for example, on Intel DQ45CB motherboard), Device Manager (START / SETTINGS / CONTROL_PANEL / SYSTEM / DEVICE_MANAGER) shows "High Precision Event Timer" device in "System devices" branch. But this device has no driver and is not used at all. Windows Server 2003
Windows Server 2003
Windows Server 2003 is a server operating system produced by Microsoft, introduced on 24 April 2003. An updated version, Windows Server 2003 R2, was released to manufacturing on 6 December 2005...
, and earlier Windows
Microsoft Windows
Microsoft Windows is a series of operating systems produced by Microsoft.Microsoft introduced an operating environment named Windows on November 20, 1985 as an add-on to MS-DOS in response to the growing interest in graphical user interfaces . Microsoft Windows came to dominate the world's personal...
versions, Linux
Linux
Linux is a Unix-like computer operating system assembled under the model of free and open source software development and distribution. The defining component of any Linux system is the Linux kernel, an operating system kernel first released October 5, 1991 by Linus Torvalds...
kernels prior to 2.6.With a Linux kernel
Linux kernel
The Linux kernel is an operating system kernel used by the Linux family of Unix-like operating systems. It is one of the most prominent examples of free and open source software....
, you need the newer "rtc-cmos" hardware clock device driver rather than the original "rtc" driver.
The following operating systems are known to be able to use HPET:
Windows XP
Windows XP
Windows XP is an operating system produced by Microsoft for use on personal computers, including home and business desktops, laptops and media centers. First released to computer manufacturers on August 24, 2001, it is the second most popular version of Windows, based on installed user base...
,On XP SP3 the IRQ0 and IRQ8 are often both mapped to a "High Precision Event Timer" when using the ACPI HAL (version 5.1.2600.5512), albeit that the QueryPerformanceFrequency API call returns a value related to the rated processor clock speed (e.g. 2.6GHz) rather than the Intel HPET spec'd value of 15MHz that you would get using Vista. This anomaly muddies the water about what is meant by "HPET" on such systems, but it is clearly not the 15MHz Intel device in those cases. On any system, the quoted frequency has to be stable in order to qualify for QueryPerformanceFrequency, so the quoted CPU-based clock speed is clearly not an ongoing reading of the CPU core frequency itself. However, its high value implicates the TSC (Time Stamp Counter) mechanism as being the basis of this apparent "HPET". Note that this IRQ mapping and clock relationship can be found both on Intel systems and AMD systems that are not using the /USEPMTIMER boot override. There can be concerns over the stability of the TSC-derived QueryPerformanceCounter readings on multicore systems as the actual frequency (i.e. not the reported frequency) may vary. Whilst the most recent ACPI HAL apparently includes code to synchronize the counters between processors, it is not entirely clear how it deals with variations in frequency under power management or the deliberate clock dither (spread-spectrum settings) that can be set in the BIOS.
On both Intel and AMD machines using the ACPI HAL together with the /USEPMTIMER boot switch, the IRQs 0 & 8 will still report a HPET, but now the QueryPerformanceFrequency will report 3.579545MHz, which is the frequency of the PMTIMER. This has the express advantage of being independent of the CPU frequency and still provides a very reasonable sub-microscecond resolution and accuracy.
With or without the /PMTIMER switch, the "event" part of the HPET specification can only be emulated, since neither underlying solution includes implicit hardware for aperiodic event triggering as described by the specification, and yet this is available via the timer API in XP (to a best possible resolution of 0.9766ms). This part of the specification is most probably still fulfilled by the RTC or similar device with the help of software, despite the fact that the device manager is quoting HPET in the IRQ0 and IRQ8 positions.
So it appears that the term "High Precision Event Timer" was already being used to describe TSC (Time-Stamp-Counter) and PMTimer systems before the 15MHz Intel HPET came into being. So whilst it is true to say that only Vista and later Windows use the Intel 15MHz HPET, the terminology of HPET exists for Windows XP, albeit to a different specification and reduced capability. In short, XP SP3 "emulates" most of the HPET specification (drafted in 2002) in anticipation of a device that made its eventual appearance in PCs designed for Windows Vista by 2005. Windows 2008, Windows Vista
Windows Vista
Windows Vista is an operating system released in several variations developed by Microsoft for use on personal computers, including home and business desktops, laptops, tablet PCs, and media center PCs...
, Windows 7, x86 based versions of Mac OS X
Mac OS X
Mac OS X is a series of Unix-based operating systems and graphical user interfaces developed, marketed, and sold by Apple Inc. Since 2002, has been included with all new Macintosh computer systems...
, Linux
Linux
Linux is a Unix-like computer operating system assembled under the model of free and open source software development and distribution. The defining component of any Linux system is the Linux kernel, an operating system kernel first released October 5, 1991 by Linus Torvalds...
operating systems using the 2.6 kernel, FreeBSD
FreeBSD
FreeBSD is a free Unix-like operating system descended from AT&T UNIX via BSD UNIX. Although for legal reasons FreeBSD cannot be called “UNIX”, as the direct descendant of BSD UNIX , FreeBSD’s internals and system APIs are UNIX-compliant...
and OpenSolaris
OpenSolaris
OpenSolaris was an open source computer operating system based on Solaris created by Sun Microsystems. It was also the name of the project initiated by Sun to build a developer and user community around the software...
.
Problems
HPET is a continuously running timer that counts upward, not a one-shot device that counts down to zero, causes one interrupt and then stops. Since HPET compares the actual timer value and the programmed target value on equality rather than "greater or equal", interrupts can be missed if the target time has already passed when the comparator value is written into the chip's register. In the presence of non-maskable interruptNon-Maskable interrupt
A non-maskable interrupt is a computer processor interrupt that cannot be ignored by standard interrupt masking techniques in the system. It is typically used to signal attention for non-recoverable hardware errors...
s (such as System Management Interrupts
System Management Mode
System Management Mode is an operating mode in which all normal execution is suspended, and special separate software is executed in high-privilege mode. It was first released with the Intel 386SL...
) that do not have a hard upper bound on their execution time, this race condition
Race condition
A race condition or race hazard is a flaw in an electronic system or process whereby the output or result of the process is unexpectedly and critically dependent on the sequence or timing of other events...
requires time-consuming re-checks of the timer after setup and is hard to avoid completely. The difficulties are exacerbated if the comparator value is not synchronized with the timer immediately, but delayed by one or two ticks, as some chipsets do.
See also
- Programmable Interval TimerProgrammable Interval TimerIn computing and in embedded systems, a programmable interval timer is a counter which triggers an interrupt when it reaches the programmed count.- Common features :...
- Advanced Programmable Interrupt ControllerAdvanced Programmable Interrupt ControllerIn computing, an Advanced Programmable Interrupt Controller is a more complex Programmable Interrupt Controller than Intel's original types such as the 8259A...
- Time Stamp CounterTime Stamp CounterThe Time Stamp Counter is a 64-bit register present on all x86 processors since the Pentium. It counts the number of ticks since reset. The instruction "RDTSC" returns the TSC in EDX:EAX. In x86_64 mode, RDTSC also clears the higher 32 bits of RAX. Its opcode is 0F 31. Pentium competitors such as...