U++ framework
Do not panic. Ask here before giving up.

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: 1796
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 Oct 04 05:31:16 GMT+2 2026

Total time taken to generate the page: 0.00834 seconds