timer:sleep bug?

Bernardo Paroli <>
Wed May 17 16:37:53 CEST 2006


Hi,
I've been testing the timer:sleep/1 function and I have some troubles with some values passed to the function. In the test I start n process and each process make a loop sleeping for x milliseconds. Below I show the example.
If I run the test with sleepTest:start(100, 999) the test work fine, but if I run with sleepTest(100, 1000) the erlang process consume 100% cpu :(
Is this a bug? Why with 999 milliseconds work fine and with 1000 milliseconds no?

In ran the test in a Windows XP with Erlang v5.4

-module(sleepTest).

-export([start/2]).

start(0, _Sleep) ->
 ok;
 
start(N, Sleep) ->
 spawn(fun() -> loop(Sleep) end),
 timer:sleep(10),
 start(N - 1, Sleep).

loop(Sleep) ->
 timer:sleep(Sleep),
 loop(Sleep).


Regards,
Bernardo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20060517/8a6d68f8/attachment.html>


More information about the erlang-questions mailing list