<br><br><div class="gmail_quote">On Wed, Jul 1, 2009 at 4:22 PM, Igor Stasenko <span dir="ltr">&lt;<a href="mailto:siguctua@gmail.com">siguctua@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
2009/7/1 Mariano Martinez Peck &lt;<a href="mailto:marianopeck@gmail.com">marianopeck@gmail.com</a>&gt;:<br>
<div><div></div><div class="h5">&gt; Hi folks! I am doing some benchmarks and I having problems with fork (I<br>
&gt; think).<br>
&gt;<br>
&gt; I have this method collect:<br>
&gt;<br>
&gt; collect<br>
&gt; |semaphores tr|<br>
&gt; semaphores := Array new: 10.<br>
&gt; tr := ThreadSafeTranscript new.<br>
&gt; tr open.<br>
&gt; 1 to: 10 do: [ :index | semaphores at: index put: Semaphore<br>
&gt; forMutualExclusion ].<br>
&gt;<br>
&gt;     1 to: 10 do: [:i |<br>
&gt;         [<br>
&gt;         tr show: &#39;one fork&#39;; cr.<br>
&gt;         (semaphores at: i) signal.<br>
&gt;         ] fork<br>
&gt;     ].<br>
&gt;<br>
&gt;     semaphores do: [:each | each wait ].<br>
&gt;     tr show: &#39;all forks proccesed&#39;; cr.<br>
&gt;<br>
&gt;<br>
&gt; What I want is that the method collect returns when ALL of the forks created<br>
&gt; inside, are finished. Obviously in my real code, I don&#39;t do a transcript<br>
&gt; show: but another thing.<br>
&gt;<br>
&gt; I would expect something like this:<br>
&gt;<br>
&gt; one fork<br>
&gt; one fork<br>
&gt; one fork<br>
&gt; one fork<br>
&gt; one fork<br>
&gt; one fork<br>
&gt; one fork<br>
&gt; one fork<br>
&gt; one fork<br>
&gt; one fork<br>
&gt; all forks proccesed<br>
&gt;<br>
&gt; But the output is:<br>
&gt;<br>
&gt;<br>
&gt; all forks proccesed<br>
&gt; one fork<br>
&gt; one fork<br>
&gt; one fork<br>
&gt; one forkone fork<br>
&gt; one fork<br>
&gt; one fork<br>
&gt; one forkone fork<br>
&gt; one fork<br>
&gt; one fork<br>
&gt; one forkone fork<br>
&gt;<br>
&gt; So, I guess it isn&#39;t working :(   I don&#39;t know too much about forks so any<br>
&gt; help is welcome!<br>
&gt;<br>
&gt; can be a problem with  ThreadSafeTranscript  ? If so, how could I test if my<br>
&gt; code is working as expected ?<br>
&gt;<br>
<br>
</div></div>Mariano, sorry it way my mistake. In example that i gave you on IRC ,<br>
i put Semaphore forMutualExclusion,<br>
while obviously it should be simply: Semaphore new.<br>
</blockquote><div><br>Sorry, I was having lunch. <br><br>Igor: I didn&#39;t know that sig__ where you :)   Actually, I was just doing some tests and saw that using Semaphore new instead of Semaphore forMutualExclusion  do what I wanted. I then saw forMutualExclusion implementation and it does a signal after the new :)<br>
<br>Thanks for the help!!<br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
<br>
<br>
&gt; Thanks,<br>
&gt;<br>
&gt; Mariano<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
<font color="#888888"><br>
<br>
<br>
--<br>
Best regards,<br>
Igor Stasenko AKA sig.<br>
<br>
</font></blockquote></div><br>