• entries
    205
  • comments
    228
  • views
    112869

Wasting time on timers

Sign in to follow this  
Mike Bossy

68 views

Thanks to a journal posting by Extrarius I decided to do some research into all the problems I've heard about using QueryPerformanceCounter on multi-core machines. I knew what the problem was going in, bascally making that call on different cores can give you wacky results between cores and in a multi-tasking OS you could run on one core for one frame and then another core the next frame. I also knew a suggested fix, just set your thread affinity so your timer thread is always running on the same CPU. What I wanted to know was if there was a better way to do timing.

What I found out was that it's possible to waste hours reading crap on the internet and have no better solution at the end of your time. The basic gist of my research is that there is no way to do accurate real-time work on a modern computer and "Guarantee" that it will work flawlessly. Even on a single proc machine let alone a multi-core machine with BIOS problems where cores get out of sync.

This realization scared the crap out of me at first until I realized that there have been hundreds and thousands of games released over the years that had this problem and are fine. The reality is that the world is an imperfect place so why should computer times be any different?

So I'm going to keep using QPC and just set the thread affinity like I said in the first place to take care of the multi-core problem. Outside of that you're all on your own!
Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now