Knowledge (XXG)

High Precision Event Timer

Source 📝

553:
Management Timer (PMTimer) timing subsystems even when the 15 MHz Intel HPET device is not being used. While it is true to say that only Windows Vista and later Windows use the physical Intel 15 MHz HPET, the operating system features intended to be fulfilled by the HPET already largely existed in Windows XP, albeit to a different specification (that of 2002 rather than 2005) and hence with a reduced capability. In terms of physical embodiment in Windows XP SP3, the IRQ0 and IRQ8 are typically 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 (for example, 2.6 GHz) or PMTIMER (3.579545 MHz) rather than the Intel HPET spec'd value of 15 MHz that you would get using Windows Vista. This anomaly muddies the water about what is meant by "HPET" on such systems, but it is clearly not the 15 MHz Intel device in those cases. Note that this "HPET"-quoting IRQ mapping and non-HPET clock relationship can be found both on Intel systems and AMD systems whether or not they are using the /USEPMTIMER boot override. Since the original specification for HPET (in 2002) calls for a high resolution counter, which is then exposed by the QueryPerformanceFrequency and QueryPerformanceCounter API calls (already available since Windows 2000), it is the QueryPerformanceFrequency that can shed light on how this "high precision" counter is actually being provided. A high value (in the 1 GHz to 4 GHz range) implicates the Time Stamp Counter (TSC) of the CPU as being the source. The early multi-core CPUs from AMD exposed a problem with TSC-derived QueryPerformanceCounter readings, as they would be affected by spread-spectrum and power management speed variations. While this was eventually solved in later processor designs by making the TSC clock independent of the CPU clock, the PM Timer on ACPI systems became the counter source of choice, requiring a /USEPMTIMER override in the Windows BOOT.INI file to enforce its use. 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.579545 MHz, 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-microsecond resolution and accuracy. Ironically the very high count rates obtained in TSC mechanisms (as compared with PMTIMER or the Intel HPET device) can cause a problem that the measurable time intervals are too short: there is an upper limit to the usefulness of a counter that overflows early. It can also be a nuisance that the ever-increasing processor speeds of newer processor designs make this usable time span shorter still. It is thus not surprising that PMTIMER and Intel HPET systems use a clearly specified fixed rate that is deliberately targeted at producing resolutions in the sub-microsecond range, allowing them to measure for longer periods than is possible with TSC. With or without the /PMTIMER switch, the "event" part of the HPET specification can only be emulated by using yet another timing source, since neither an underlying TSC nor PMTIMER solution includes implicit hardware for aperiodic event triggering as described by the specification, and yet this is available via the timer API in Windows XP (to a best possible resolution of 0.9766 ms when the timeBeginPeriod - timeEndPeriod API calls are used). This part of the specification is still fulfilled by the RTC device with the help of software, despite the fact that the device manager is quoting HPET in the IRQ0 and IRQ8 positions.
360: 278: 351:
several short (some milliseconds, perhaps) waits, it is better to have a periodic timer running constantly with a 1 ms period because of the high setup cost of an 8254 or RTC one-shot timer. This causes an interrupt at 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.
25: 199:(TSC), or ACPI Power Management Timer (ACPI PMTIMER), together with the RTC to provide operating system features that would, in later Windows versions, be provided by the HPET hardware. Confusingly, such Windows XP systems quote "HPET" connectivity in the device driver manager even though the Intel HPET device is not being used. 480:
document also lists some other drawbacks: "The specification does not require the timer to be particularly fine grained, to have low drift, or to be fast to read. Some typical implementations run the counter at about 18 MHz and require about the same amount of time (1–2 μs) to read the HPET
443:
version 2 states that TSC is the preferred clock source due to its much lower overhead, but it uses HPET as a fallback. A benchmark in that environment for 10 million event counts found that TSC took about 0.6 seconds, HPET took slightly over 12 seconds, and ACPI Power Management Timer took around 24
552:
XP SP3 "emulates" most of the HPET specification as drafted in 2002 in anticipation of a device that made its eventual appearance in PCs designed for Windows Vista by 2005. The term "High Precision Event Timer" is then used within the driver manager to describe TSC (Time-Stamp-Counter) or ACPI Power
459:
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
230:
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
509:
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 system's 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
350:
be put into an HPET-like 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 a very small time interval. For example, if an application needs to perform
371:
Operating systems designed before HPET existed cannot use HPET, so they use other timer facilities. Newer operating systems tend to be able to use either. Some hardware has both. Indeed, most current southbridge chips have legacy-supporting instances of PIT, PIC,
472:
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.
242:
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
460:
time has already passed when the comparator value is written into the chip's register. In such a case, not only is the intended interrupt missed, but actually set far into the future (about 2 or 2 counts). In the presence of
312:
programmable interval timer and the RTC's periodic interrupt function. Compared to these older timer circuits, the HPET has higher frequency and wider 64-bit counters (although they can be driven in 32-bit mode).
530:
DQ45CB motherboard), Device Manager (Start / Settings / Control Panel / System / Device Manager) shows "High Precision Event Timer" device in "System devices" branch. But this device is not used at all.
687: 211:(main counter) counting at a frequency of at least 10 MHz, and a set of (at least three, up to 256) comparators. These comparators are 32- or 64-bit-wide. The HPET is programmed via a 740: 231:
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.
253:
instruction. This provides improved efficiency, since the CPU does not need to waste cycles to make up for the low resolution of timers, and enables more aggressive use of
376:(APIC) and RTC devices incorporated into their silicon whether or not they are used by the operating system, which helps very modern PCs run older operating systems. 622: 691: 577: 140:. Compared to older types of timers available in the x86 architecture, HPET allows more efficient processing of highly timing-sensitive applications, such as 42: 373: 216: 735: 89: 257:, reducing power consumption. In addition to the application-level demand for high-precision clock, there are OS-level benefits in the 61: 108: 481:
as with the ACPI timer. Implementations have been observed in which the period register is off by 800 parts per million or more."
68: 46: 75: 712: 234:
Comparators can be driven by the operating system, e.g. to provide one timer per CPU for scheduling, or by applications.
777: 57: 465: 180: 320:
of 10 MHz; the actual frequency is provided to the operating system by a hardware register giving the number of
192: 35: 262: 359: 395: 220: 461: 403: 258: 165: 145: 82: 164:, the term HPET was selected to avoid confusion with the software multimedia timers introduced in the 759: 399: 647: 447:
In 2019 it was decided to blacklist HPET in newer Linux kernels when running on some Intel CPUs (
196: 137: 669: 601: 543:, you need the newer RTC-CMOS hardware clock device driver rather than the original RTC driver. 384: 212: 208: 176: 130: 179:
that do not support a hardware HPET device can only use older timing facilities, such as the
760:
Timekeeping in VMware Virtual Machines (for VMware vSphere 5.0, Workstation 8.0, Fusion 4.0)
506: 526:
the HPET timer (as a device with ACPI\PNP0103 identifier). When detected (for example, on
184: 469: 277: 771: 744: 407: 540: 436: 501:
often sets up the HPET incorrectly in the ACPI, initializing it correctly only in
394:
The following operating systems are known to be able to use HPET: Windows XP SP3,
448: 440: 429: 321: 169: 157: 24: 519: 502: 309: 188: 141: 316:
The HPET specification does not define the timer frequency, only requiring a
510:
second HPET at page 0xFED80000 (see the discussion for further information).
411: 254: 227: 153: 717: 468:(SMI)) that do not have a hard upper bound on their execution time, this 425: 579:
IA-PC HPET (High Precision Event Timers) Specification (revision 1.0a)
477: 288: with: compare with LAPIC timer, ACPI PM etc.. You can help by 527: 421: 388: 367:
boot log showing the switch from HPET to TSC as system clocksource
364: 358: 249: 149: 498: 416: 272: 244: 134: 18: 439:
can also use HPET as its clock source. The documentation of
476:
Besides mentioning the race condition discussed above, a
623:"IA-PC HPET (High Precision Event Timers) Specification" 339: MHz, 12 times the standard 8254 frequency of 1.193 261:
and through the availability of a stable clock base for
219:. The HPET circuit in modern PCs is integrated into the 713:"The Linux Kernel Disabling HPET For Intel Coffee Lake" 289: 383:
to be able to use HPET: Windows XP SP1, and earlier
424:operating systems using the 2.6 kernel (or later), 49:. Unsourced material may be challenged and removed. 649:Guidelines For Providing Multimedia Timer Support 160:since 2005. Formerly referred to by Intel as a 505:mode. If the ACPI is not set up correctly the 8: 308:HPET is meant to supplement and replace the 747:, commit merged for Linux kernel 2.6.36-rc5 730: 728: 571: 569: 379:The following operating systems are known 374:Advanced Programmable Interrupt Controller 755: 753: 737:x86: hpet: Work around hardware stupidity 109:Learn how and when to remove this message 16:Hardware timer used in personal computers 565: 490: 7: 497:On these highly integrated dies the 195:(HAL), can also use the processor's 47:adding citations to reliable sources 690:. Access.redhat.com. Archived from 324:per period (with an upper bound of 576:Intel Corporation (October 2004), 207:An HPET chip consists of a 64-bit 14: 276: 226:Each comparator can generate an 215:window that is discoverable via 23: 34:needs additional citations for 451:) because of its instability. 191:, when fitted with the latest 148:. It was developed jointly by 1: 156:and has been incorporated in 670:"FreeBSD Man Pages: hpet(4)" 58:"High Precision Event Timer" 466:System Management Interrupt 335:). A popular value is 14.3 181:programmable interval timer 794: 688:"Chapter 15. Timestamping" 269:Comparison to predecessors 193:hardware abstraction layer 133:timer available in modern 123:High Precision Event Timer 414:, x86 based versions of 462:non-maskable interrupts 396:Windows Server 2003 SP2 404:Windows Server 2008 R2 391:kernels prior to 2.6. 368: 628:. Intel. October 2004 362: 355:Use and compatibility 166:MultiMedia Extensions 43:improve this article 778:Integrated circuits 602:"Multimedia Timers" 400:Windows Server 2008 346:While 8254 and RTC 369: 197:Time Stamp Counter 138:personal computers 734:Thomas Gleixner, 306: 305: 213:memory mapped I/O 177:operating systems 119: 118: 111: 93: 785: 763: 757: 748: 732: 723: 722: 709: 703: 702: 700: 699: 684: 678: 677: 666: 660: 659: 658: 657: 644: 638: 637: 635: 633: 627: 619: 613: 612: 610: 609: 598: 592: 591: 590: 589: 584: 573: 554: 550: 544: 537: 531: 517: 511: 495: 419: 342: 338: 334: 332: 329: 301: 298: 280: 273: 252: 221:southbridge chip 162:Multimedia Timer 144:playback and OS 114: 107: 103: 100: 94: 92: 51: 27: 19: 793: 792: 788: 787: 786: 784: 783: 782: 768: 767: 766: 758: 751: 733: 726: 711: 710: 706: 697: 695: 686: 685: 681: 674:www.freebsd.org 668: 667: 663: 655: 653: 646: 645: 641: 631: 629: 625: 621: 620: 616: 607: 605: 600: 599: 595: 587: 585: 582: 575: 574: 567: 563: 558: 557: 551: 547: 538: 534: 518: 514: 496: 492: 487: 457: 415: 357: 340: 336: 330: 327: 325: 302: 296: 293: 286:needs expansion 271: 263:multi-processor 248: 240: 205: 185:real-time clock 115: 104: 98: 95: 52: 50: 40: 28: 17: 12: 11: 5: 791: 789: 781: 780: 770: 769: 765: 764: 749: 743:2012-07-09 at 724: 704: 679: 661: 639: 614: 593: 564: 562: 559: 556: 555: 545: 532: 512: 489: 488: 486: 483: 470:race condition 456: 453: 356: 353: 304: 303: 283: 281: 270: 267: 239: 236: 204: 201: 146:task switching 135:x86-compatible 117: 116: 31: 29: 22: 15: 13: 10: 9: 6: 4: 3: 2: 790: 779: 776: 775: 773: 761: 756: 754: 750: 746: 745:archive.today 742: 739: 738: 731: 729: 725: 720: 719: 714: 708: 705: 694:on 2016-05-07 693: 689: 683: 680: 675: 671: 665: 662: 651: 650: 643: 640: 624: 618: 615: 603: 597: 594: 581: 580: 572: 570: 566: 560: 549: 546: 542: 536: 533: 529: 525: 521: 516: 513: 508: 504: 500: 494: 491: 484: 482: 479: 474: 471: 467: 463: 454: 452: 450: 445: 442: 438: 433: 431: 427: 423: 418: 413: 409: 408:Windows Vista 405: 401: 397: 392: 390: 386: 382: 377: 375: 366: 361: 354: 352: 349: 344: 323: 319: 314: 311: 300: 297:February 2014 291: 287: 284:This section 282: 279: 275: 274: 268: 266: 264: 260: 256: 251: 246: 237: 235: 232: 229: 224: 222: 218: 214: 210: 202: 200: 198: 194: 190: 186: 183:(PIT) or the 182: 178: 173: 171: 167: 163: 159: 155: 151: 147: 143: 139: 136: 132: 128: 124: 113: 110: 102: 99:February 2014 91: 88: 84: 81: 77: 74: 70: 67: 63: 60: –  59: 55: 54:Find sources: 48: 44: 38: 37: 32:This article 30: 26: 21: 20: 736: 716: 707: 696:. Retrieved 692:the original 682: 673: 664: 654:, retrieved 652:, 2002-09-20 648: 642: 630:. Retrieved 617: 606:. Retrieved 596: 586:, retrieved 578: 548: 541:Linux kernel 535: 523: 515: 493: 475: 458: 446: 437:Linux kernel 434: 393: 380: 378: 370: 347: 345: 322:femtoseconds 317: 315: 307: 294: 290:adding to it 285: 255:sleep states 241: 238:Applications 233: 225: 206: 174: 161: 126: 122: 120: 105: 96: 86: 79: 72: 65: 53: 41:Please help 36:verification 33: 604:. Microsoft 464:(such as a 449:Coffee Lake 441:Red Hat MRG 430:OpenSolaris 343: MHz. 170:Windows 3.0 158:PC chipsets 698:2014-02-14 656:2009-11-10 608:2010-10-20 588:2012-06-15 561:References 520:Windows XP 503:Intel 8253 387:versions, 209:up-counter 189:Windows XP 142:multimedia 69:newspapers 632:30 August 444:seconds. 412:Windows 7 265:systems. 259:scheduler 245:x86-based 228:interrupt 154:Microsoft 772:Category 762:, page 9 741:Archived 718:Phoronix 455:Problems 333: fs 203:Features 131:hardware 539:With a 426:FreeBSD 385:Windows 318:minimum 187:(RTC). 129:) is a 83:scholar 522:, SP2 478:VMware 247:CPU's 175:Older 85:  78:  71:  64:  56:  626:(PDF) 583:(PDF) 528:Intel 524:knows 485:Notes 422:Linux 389:Linux 365:Linux 250:RDTSC 150:Intel 90:JSTOR 76:books 634:2022 499:BIOS 435:The 428:and 417:OS X 310:8254 217:ACPI 152:and 127:HPET 121:The 62:news 381:not 348:can 331:000 328:000 326:100 292:. 168:to 45:by 774:: 752:^ 727:^ 715:. 672:. 568:^ 507:OS 432:. 420:, 410:, 406:, 402:, 398:, 363:A 341:18 337:18 223:. 172:. 721:. 701:. 676:. 636:. 611:. 299:) 295:( 125:( 112:) 106:( 101:) 97:( 87:· 80:· 73:· 66:· 39:.

Index


verification
improve this article
adding citations to reliable sources
"High Precision Event Timer"
news
newspapers
books
scholar
JSTOR
Learn how and when to remove this message
hardware
x86-compatible
personal computers
multimedia
task switching
Intel
Microsoft
PC chipsets
MultiMedia Extensions
Windows 3.0
operating systems
programmable interval timer
real-time clock
Windows XP
hardware abstraction layer
Time Stamp Counter
up-counter
memory mapped I/O
ACPI

Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.