Skip to content
Tcl Source Code View Ticket
Login

View Ticket

MS-Win Time: why not use GetSystemTimePreciseAsFileTime()

Open7e47f5599321684435b0216832f5555c7f3c3df7Created 1 year agoUpdated 1 year ago
Descriptionwiki2025-11-15 10:07:56
I am still reading the MS-Windows Win32 API documentation.

This documentation proposes to use the function GetSystemTimePreciseAsFileTime() for UTC based high resolution time:

https://learn.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getsystemtimepreciseasfiletime

Would that be a replacement for the MS-Win Tcl_Time() implementation featuring an own calibration thread.

The comments in TCL why this is required reference Pentium 4 processors and Windows SE.

I already asked a similar question [1238d4fdb0] where the answer was, that the old API is still required for Windows 8 (even if documented as superseeded in Windows XP).

Thanks for any light, Harald

apnadkarnimarkdown2025-11-15 11:13:28

I am a little confused here. Isn't the calibration thread required for measuring time intervals? The GetSystemTimePreciseAsFileTime function returns UTC based time which would not be the same thing, would it? (monotonicity, leap seconds if they have not been banned yet etc.)

oehharplain2025-11-15 12:50:28
It is used for Tcl_GetTime().

The resulting time intervals are between two wall clock moments.
So, one monotonic second may be plus or minus one hour, if the wall clock jumps by +/- 1 hour between the diff calls.

The use of Tcl_GetTime() for time intervals (like the time command or interp limit) is IMHO a miss-use.

Thanks for all,
Harald
Log in (anonymous is fine) to add a comment.