[erlang-questions] there is a blocking in the process evaluatingthe huge factorial
Fri Jun 3 10:53:12 CEST 2011
but the same behavior if i make this below (io:format doesn't matter). Start S3() wait for a 3 seconds and try to type something. the typing will appear after factorial will be evaluated. BUT sometimes i can typing. It's very strange. (PS. i don't know if this answer will be posted right, because erlang-questions forum is strange for me, i didn't find any buttons like Reply or Answer, i've only made Reply All in my mail web tool.)
5> S3 = fun()-> spawn(Fac) end.
Thu, 2 Jun 2011 11:54:43 -0700 письмо от Mike Oxford <>:
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... http://www.trapexit.org/forum/viewtopic.php?p=43855
Again, just a guess. :)
On Thu, Jun 2, 2011 at 7:27 AM, systemio systemio <> wrote:
My Erlang is (Erlang R13B03 (erts-5.7.4) [smp:2:2] [rq:2] [async-threads:0]).
I've found the strange behavior when i spawn the process to evaluate the huge
Here is the factorial module:
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", ),
3> S2 = fun()-> spawn(Fac), io:format("Will I am", ), spawn(Fac) end.
Will I am<0.38.0>
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 "i()."
and hit enter. This command is blocked and result appeares after 11 sec until
second process evaluates.
if i start S2() i will see the message "Will i am" immediately but i will not
be able to type anything in the shell and my typing will appear after 22 sec.
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