Jump to content
  • Advertisement
Sign in to follow this  
Idov

Mulimedia timers

This topic is 2790 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi!
I'm trying to suspend a thread of mine for less the 1 milisecond, so i was thinking of using a multimedia timer.
I came across this article
http://www.codeguru....icle.php/c5759/
which is supposed to do exactly that. but It doesn't work well and I was wondering if anybody here maybe has a better solution or knows how can I do it?
(I'm using C++ on windows)

thanks :)

Share this post


Link to post
Share on other sites
Advertisement

Hi!
I'm trying to suspend a thread of mine for less the 1 milisecond, so i was thinking of using a multimedia timer.


Unless you are on a real-time OS, or use a custom built and configured kernel, thread granularity will be about 20ms. Anything that relinquishes control or any set of consequctive actions that takes longer than that may at any point be interrupted by the OS.

The best way to do high accuracy delays would be to constrain a thread to a specific core, then use RDTSC to count cycles in a busy loop. But it will peg that core even when doing no work and may require adjusting for CPU power mode switches, perhaps by comparing to some other timer.

Anything else that involves IO or allows threads to be switched shouldn't rely on times less than 40ms or so. Or anything really, PCs simply don't have good hardware support for it. It's also perfectly possible for various PC configurations to simply not have a high resolution timer exposed via one of OS API calls.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!