[erlang-questions] there is a blocking in the process evaluating the huge factorial
Thu Jun 2 20:54:43 CEST 2011
As a guess; io:format sends the message to the group leader for output.
If your group leader were to change based on the spawn() call, you may have
your io:format message in the run queue behind the fac call.
More information may be found here...
Again, just a guess. :)
On Thu, Jun 2, 2011 at 7:27 AM, systemio systemio <systemio@REDACTED> wrote:
> Hi all,
> My Erlang is (Erlang R13B03 (erts-5.7.4) [smp:2:2] [rq:2]
> WinXP SP1.
> I've found the strange behavior when i spawn the process to evaluate the
> Here is the factorial module:
> fac(0) ->
> fac(N) ->
> N * fac(N-1).
> Here is the Erlang Shell code:
> 1> Fac = fun() -> test:fac(100000) end.
> 2> S1 = fun()-> spawn(Fac), timer:sleep(3000), io:format("Will I am", ),
> spawn(Fac) end.
> 3> S2 = fun()-> spawn(Fac), io:format("Will I am", ), spawn(Fac) end.
> 4> S1().
> Will I am<0.38.0>
> 5> S2().
> Will I am<0.42.0>
> In my PC the fun Fac evaluates about 11 sec.
> If i start S1() i will see the message "Will I am" after 14 sec and it is
> strange as i expect it after 3 seconds. After message appeares i type
> and hit enter. This command is blocked and result appeares after 11 sec
> second process evaluates.
> if i start S2() i will see the message "Will i am" immediately but i will
> be able to type anything in the shell and my typing will appear after 22
> Also i've tested it with spawn(Node, ...) and the result is IAE same.
> Are these behaviors valid or do i do smth wrong?
> erlang-questions mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions