Windows APIのタイムアウト指定待機関数では、指定期間よりも僅かに早くタイムアウト発生する。この振る舞いは仕様通り(by design)とのこと。
WaitForSingleObject
,WaitForSingleObjectEx
WaitForMultipleObjects
,WaitForMultipleObjectsEx
MsgWaitForMultipleObjects
,MsgWaitForMultipleObjectsEx
- etc.
Windows OSのデフォルトタイマ割込間隔は 64 [Hz]=15.625 [msec] となっているため、平均的に数ミリ秒だけ早くタイムアウトが発生しうる。
Wait Functions and Time-out Intervals
https://docs.microsoft.com/windows/win32/sync/wait-functions
The accuracy of the specified time-out interval depends on the resolution of the system clock. The system clock "ticks" at a constant rate. If the time-out interval is less than the resolution of the system clock, the wait may time out in less than the specified length of time. If the time-out interval is greater than one tick but less than two, the wait can be anywhere between one and two ticks, and so on.
関連URL