4 ms·
What's preventing PC's from having some realtime clock hardware component that could be used by software?
by devwastaken 5y ago
What's preventing PC's from having some realtime clock hardware component that could be used by software?
- krona 5y agoModern CPU's already have several counters for 'nominal' cycles (i.e. cycles at a constant frequency). e.g. TSC instructions and Performance-Monitoring Counters. Converting nominal cycles to time can be unreliable in some cases but not impossible.
- flohofwoe 5y agoThis isn't the problem, those timers exist and are accessible (unless you're in a web browser). The problem is that your code is essentially running at an unpredictable point in time within the current frame. E.g. if you measure the time duration between the same line of code at the start of your per-frame function you'll get a tiny jitter and never exactly 16.66667 ms (assuming a 60Hz display). I'm not sure what's the exact reason, but I guess there are many things that can throw off this sort of time measurement in a modern operating system (for instance process/thread scheduling).