Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » running program at different speeds
Re: running program at different speeds [message #37013 is a reply to message #37012] Wed, 08 August 2012 13:55 Go to previous messageGo to previous message
dolik.rce is currently offline  dolik.rce
Messages: 1791
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

On POSIX platforms Sleep() is implemented using nanosleep function. If you look in manual for this function it says this:
man nanosleep

The suspension time may be longer than requested because the argument value is rounded up to an integer multiple of the sleep resolution or because of the scheduling of other activity by the system.

Very similar conditions hold AFAIK for the windows implementation.

In addition (at least on POSIX) it is possible that Sleep returns earlier then it is supposed, if it is interrupted by a signal from outside.

If you need to get more precise speed adjustments, you might want to try longer Sleep() less often (e.g. every n-th iteration of the loop).

Honza
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Add layout
Next Topic: Trouble with Socket
Goto Forum:
  


Current Time: Sun Jun 08 09:55:40 CEST 2025

Total time taken to generate the page: 0.04001 seconds