Home > Backend Development > C++ > body text

**How Does GetSystemTimeAdjustment Misrepresent System Time Increments?**

DDD
Release: 2024-11-02 20:59:30
Original
887 people have browsed it

**How Does GetSystemTimeAdjustment Misrepresent System Time Increments?**

How GetSystemTimeAdjustment Misleads on System Time Increments

While the GetSystemTimeAdjustment function provides insights into system time adjustments, it doesn't accurately reflect the actual interval and increment used to update the system clock, as evidenced by empirical observations.

Assumption Validity

Your assumption that timestamps returned by GetSystemTimeAsFileTime should exhibit no change or multiples of the increment retrieved by GetSystemTimeAdjustment is correct, provided the system time is being synchronized periodically.

Reason for Discrepancy

The discrepancy stems from the fact that GetSystemTimeAsFileTime's 10 ns resolution far exceeds the actual update period of the system clock. On modern systems, the clock is typically incremented in increments of 0.0025 seconds, not the 0.0156 seconds reported by GetSystemTimeAdjustment.

This mismatch arises because GetSystemTimeAsFileTime records the changes in the system time at its higher resolution than the actual clock update. As a result, the observed changes do not align with the reported increment.

Implications and Alternative

Rather than relying on GetSystemTimeAdjustment, use NtQueryTimerResolution to determine the actual update period of the system time in 100 ns units. Note that the value returned by NtQueryTimerResolution can be set using NtSetTimerResolution or the multimedia timer interface. However, this setting may impact the observed values, especially when multimedia applications are active.

To accurately capture system time transitions, monitor the FILETIME values returned by GetSystemTimeAsFileTime. By looking at the difference between consecutive calls, you can measure the actual time increment.

The above is the detailed content of **How Does GetSystemTimeAdjustment Misrepresent System Time Increments?**. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!