<br><br><div class="gmail_quote">On Dec 21, 2007 10:41 AM, Igor Stasenko &lt;<a href="mailto:siguctua@gmail.com">siguctua@gmail.com</a>&gt; wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">On 20/12/2007, Michael van der Gulik &lt;<a href="mailto:mikevdg@gmail.com">mikevdg@gmail.com</a>&gt; wrote:<br>&gt;<br>&gt;<br>&gt; On Dec 21, 2007 8:09 AM, Igor Stasenko &lt;<a href="mailto:siguctua@gmail.com">
siguctua@gmail.com</a>&gt; wrote:<br>&gt; &gt;<br>&gt; &gt; On 20/12/2007, Tom Phoenix &lt;<a href="mailto:rootbeer@redcat.com">rootbeer@redcat.com</a>&gt; wrote:<br>&gt; &gt; &gt; On 12/20/07, Igor Stasenko &lt;<a href="mailto:siguctua@gmail.com">
siguctua@gmail.com</a>&gt; wrote:<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; &gt; This is essentially useful when you need to guarantee that process<br>&gt; &gt; &gt; &gt; will stay suspended even if it&#39;s currently suspended waiting for
<br>&gt; &gt; &gt; &gt; semaphore signal.<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; Do you mean to say that your processes resume running before their<br>&gt; &gt; &gt; semaphores are signaled?<br>&gt; &gt; &gt;<br>&gt; &gt;<br>
&gt; &gt; Just try to run given code:<br>&gt; &gt;<br>&gt; &gt; | sema proc |<br>&gt; &gt; sema := Semaphore new.<br>&gt; &gt; proc := [ sema critical: [ Transcript show: &#39;Oopsie&#39; ] ] fork.<br>&gt; &gt; Processor yield.
<br>&gt; &gt; proc suspend.<br>&gt; &gt; proc resume.<br>&gt; &gt;<br>&lt;snip&gt;<br></div>No, i&#39;m specially doing Processor yield to make proc start waiting for<br>semaphore.</blockquote><div><br>Er... oh, I see. From my point of view (which consists of little format training wrt Process management), you&#39;re mis-treating these poor objects. The code would work... but I&#39;d never write code like that.
<br><br>If you want to use #critical:, you should be making the Semaphore with &quot;sema := Semaphore forMutualExclusion&quot;.<br><br>&quot;Processor yield&quot; shouldn&#39;t ever be used IMHO. It relies on particular behaviour of the scheduler. In a future version of Squeak when we properly support pthreads or we &quot;improve&quot; the behaviour of the scheduler, your code might not work as expected.
<br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="Ih2E3d"><br>&gt; I can&#39;t try this code at the moment - I don&#39;t have Squeak nearby.
<br>&gt;<br>&gt; Generally, I&#39;d rarely use Process&gt;&gt;suspend in my code. Semaphores provide<br>&gt; the behaviour that you want; a Semaphore is a linked list of waiting<br>&gt; processes. When you call #wait on a semaphore, your process gets added to
<br>&gt; the list. When you call #signal, the process at one of the ends of the list<br>&gt; (FIFO? LIFO? Can&#39;t remember) gets resumed. The effect of #suspend and<br>&gt; #resume should have no effect on the signalled/waiting state of a Process.
<br>&gt;<br>&gt; In the Launcher example that you give, it would be okay to use #suspend and<br>&gt; #resume, but there shouldn&#39;t be anything else in the image which is trying<br>&gt; to suspend or resume those processes.
<br>&gt;<br></div>Yes, i was using it like:<br><br>suspendedList := OrderedCollection new.<br>(Process allInstances select:[:proc | proc isActiveProcess not and: [<br>proc isSuspended not ]]) do: [:proc | suspendedList add: proc. proc
<br>suspend].<br><br>&lt;... do my code...&gt;<br><br>suspendedList do: [:proc | proc resume ].<br><br>But because of semaphores bug, after i sending #resume to processes<br>which waiting on semaphore signal causing them think that signal is
<br>received.<br>Btw you can try this code yourself and see how low space watcher pops<br>up scaring you to death :)<br></blockquote></div><br><br>I&#39;ll try this when I get home. I do a lot of multithreaded programming in Squeak so its important to me that this stuff works right. 
<br><br>Gulik.<br clear="all"><br>-- <br><a href="http://people.squeakfoundation.org/person/mikevdg">http://people.squeakfoundation.org/person/mikevdg</a><br><a href="http://gulik.pbwiki.com/">http://gulik.pbwiki.com/</a>