<HTML><BODY>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<span> forum is strange for me, i didn't find </span>any buttons like Reply or Answer, i've only made Reply All in my mail web tool.)<br><br>5> S3 = fun()-> spawn(Fac) end.<br>#Fun<erl_eval.20.67289768><br>6> S3().<br><0.46.0><br><span></span>7>ughuihuihiuh<br><br>Thu, 2 Jun 2011 11:54:43 -0700 письмо от Mike Oxford <moxford@gmail.com>:<br><br><blockquote style="border-left:1px solid #0857A6; margin:10px; padding:0 0 0 10px;" class="mailru-blockquote"><div id="class_1307089970">As a guess; io:format sends the message to the group leader for output.<div>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.</div><div>
<br></div><div>More information may be found here... <a target="_blank" href="http://www.trapexit.org/forum/viewtopic.php?p=43855">http://www.trapexit.org/forum/viewtopic.php?p=43855</a><br _mce_bogus="1"></div><div><br></div><div>Again, just a guess. :)</div>
<div><br></div><div>G'luck!</div><div><br></div><div>-mox</div><div><br></div><div><div class="gmail_quote">On Thu, Jun 2, 2011 at 7:27 AM, systemio systemio <span dir="ltr"><<a target="_blank" href="sentmsg?compose&To=systemio@mail.ru">systemio@mail.ru</a>></span> wrote:<br>
<blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;" class="gmail_quote">Hi all,<br>
<br>
My Erlang is (Erlang R13B03 (erts-5.7.4) [smp:2:2] [rq:2] [async-threads:0]).<br>
WinXP SP1.<br>
<br>
I've found the strange behavior when i spawn the process to evaluate the huge<br>
factorial.<br>
<br>
Here is the factorial module:<br>
-module(test).<br>
-compile(export_all).<br>
<br>
fac(0) -><br>
1;<br>
fac(N) -><br>
N * fac(N-1).<br>
<br>
Here is the Erlang Shell code:<br>
1> Fac = fun() -> test:fac(100000) end.<br>
#Fun<erl_eval.<a target="_blank" value="+12067289768">20.67289768</a>><br>
2> S1 = fun()-> spawn(Fac), timer:sleep(3000), io:format("Will I am", []),<br>
spawn(Fac) end.<br>
#Fun<erl_eval.<a target="_blank" value="+12067289768">20.67289768</a>><br>
3> S2 = fun()-> spawn(Fac), io:format("Will I am", []), spawn(Fac) end.<br>
#Fun<erl_eval.<a target="_blank" value="+12067289768">20.67289768</a>><br>
4> S1().<br>
Will I am<0.38.0><br>
5> S2().<br>
Will I am<0.42.0><br>
<br>
In my PC the fun Fac evaluates about 11 sec.<br>
<br>
If i start S1() i will see the message "Will I am" after 14 sec and it is<br>
strange as i expect it after 3 seconds. After message appeares i type "i()."<br>
and hit enter. This command is blocked and result appeares after 11 sec until<br>
second process evaluates.<br>
<br>
if i start S2() i will see the message "Will i am" immediately but i will not<br>
be able to type anything in the shell and my typing will appear after 22 sec.<br>
<br>
Also i've tested it with spawn(Node, ...) and the result is IAE same.<br>
<br>
Are these behaviors valid or do i do smth wrong?<br>
<br>
~<br>
Alex<br>
_______________________________________________<br>
erlang-questions mailing list<br>
<a target="_blank" href="sentmsg?compose&To=erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a target="_blank" href="http://erlang.org/mailman/listinfo/erlang-questions">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
</blockquote></div><br></div>
</div></blockquote><br></BODY></HTML>