gpt4 book ai didi

c++ - _ftime/Windows 内部时间如何工作?

转载 作者:可可西里 更新时间:2023-11-01 14:47:35 24 4
gpt4 key购买 nike

我在 Windows 中发现了一个有趣的问题,它允许我使 Windows 时钟(但不是硬件时钟)快速运行 - 每分钟高达 8 秒。我正在做一些背景研究来弄清楚 Windows 如何计算和更新它的内部时间(而不是它如何与 NTP 服务器同步)。任何人拥有的任何信息或您可以向我指出的任何文件都将不胜感激!

此外,如果有人知道 _ftime 的工作原理,请告诉我。

最佳答案

This MSDN article对系统时间的处理方式给出了非常简短的描述:“当系统第一次启动时,它会根据计算机的实时时钟将系统时间设置为一个值,然后定期更新时间。”另一个有趣的函数是 GetSystemTimeAdjustment ,其中有这样的话:

A value of TRUE [for lpTimeAdjustmentDisabled] indicates that periodic time adjustment is disabled. At each clock interrupt, the system merely adds the interval between clock interrupts to the time-of-day clock. The system is free, however, to adjust its time-of-day clock using other techniques. Such other techniques may cause the time-of-day clock to noticeably jump when adjustments are made.

最后,关于 _ftime,它似乎是使用 GetSystemTimeAsFileTime 实现的.因此,它将直接包装到与在其他任何地方使用的相同的内置时间设施上。

关于c++ - _ftime/Windows 内部时间如何工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/212645/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com