On Wed, Apr 22, 2009 at 09:27, Michael Alipio <daem0n...@yahoo.com> wrote:
>
> Hi,
>
> I have a script that forks a child. at the parent, i have a line that tells 
> it to sleep for n seconds. Once the 3 seconds have passed, it will kill the 
> child process.
>
> I noticed that most of the time, sleep doesn't count exact seconds.. most of 
> the time it's longer. Is there any way to sleep precisely for n seconds?
snip

Not unless you are using a realtime OS.  Your process might not get
CPU time for n+m seconds.  Until your process gets CPU time it doesn't
matter what you put in sleep, nothing will happen.  You may be able to
schedule a process such that it will always have CPU time, but
performance will suffer for everything else (which is why realtime
OSes suck for everything but medical, weapon systems, and other tasks
that must have sub-microsecond timing).  You must trade speed for
precision.


-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to