nanosleep() on Windows with Visual Studio
The POSIX function nanosleep()
is not available on Windows with MSVC and certain MinGW architectures.
This
implementation of nanosleep() for Windows
uses Waitable Timer Objects.
The clock tick for Windows is 100 ns.
The practical achievable timer resolution on Windows is in the
millisecond range.
This presents a floor on the accuracy achievable for sleep timers.
Virtual Machine running of Windows makes the sleep accuracy significantly worse.
In general across general-purpose operating systems, high accuracy sleep timer performance is not guaranteed. For high accuracy sleep timers (i.e., beyond what is needed for gaming and abstract high-level control of hardware interfaces), consider using a real-time operating system (RTOS) or a dedicated microcontroller.
`