<div dir="ltr">This is not the definition of suspended that the fallback code in Process &gt;&gt; #suspend uses.<div>By its definition, when suspended, a Process is removed from all running queues, and there&#39;s no chance it will run again before being explicitly resume&#39;d. Does the primitive work differently?</div><div><br></div><div>If not, is there a simple way to check if list is nil because we are (the actual, not effective) activeProcess, nor because we have been #suspend&#39;ed, or do we need a #trueActiveProcess as well?</div><div><br></div><div>Cheers,</div><div>Henry</div><div><br></div><div>P.S. after the change to use effectiveProcess, Processor activeProcess should actually answer true when being debugged, no?</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Feb 18, 2016 at 10:22 PM, Eliot Miranda <span dir="ltr">&lt;<a href="mailto:eliot.miranda@gmail.com" target="_blank">eliot.miranda@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> <br><div dir="ltr">Hi All,<div><br></div><div>   we have a serious misunderstanding in current versions of Squeak&#39;s and Pharo&#39;s Process&gt;&gt;isSuspended.</div><div><br></div><div>Squeak&#39;s version reads</div><div><br>isSuspended</div><div><span style="white-space:pre-wrap">        </span>^myList isNil</div><div><br></div><div>Pharo&#39;s reads</div><div><br></div><div><div>isSuspended</div><div><span style="white-space:pre-wrap">        </span>^myList isNil or: [ myList isEmpty ]</div><div><br></div><div>Process&#39;s myList holds the list a process is on when it is not running.  There is only one running process at any one time, Processor activeProcess.  The active process&#39;s myList is always nil, so Squeak&#39;s and Pharo&#39;s are both wrong for the active process.</div><div><br></div><div>Processor activeProcess isSuspended =&gt; true (!!!)</div><div><br></div><div>A process may be runnable, but not running (which follows form there being only one running process, the active process, at any one time).  If it is runnable but not running its list is one of the runnable process lists in the scheduler, e.g.</div><div><div><br></div><div>Processor waitingProcessesAt: Processor activePriority =&gt; a LinkedList()</div><div>Processor waitingProcessesAt: Processor lowestPriority =&gt; a LinkedList(a Process in ProcessorScheduler class&gt;&gt;idleProcess)</div></div><div><br></div><div>Here&#39;s a couple of illustrative examples:</div><div><br></div><div><div>[Semaphore new wait] fork suspendingList</div><div>=&gt; a LinkedList(a Process in [] in BlockClosure&gt;&gt;newProcess)</div><div><br></div><div>([Semaphore new wait] forkAt: Processor activePriority + 1) suspendingList</div><div>=&gt; a Semaphore(a Process in [] in UndefinedObject&gt;&gt;DoIt)</div></div><div><br></div><div>In the first example above the new process isn&#39;t running yet.  It&#39;s runnable but hasn&#39;t got a chance to run because the active process that created it is still running.  So the process&#39;s list is Processor waitingProcessesAt: Processor activePriority.  In the second example the process has got to run, because, having higher priority, it has preempted the active process that created it.  So it suspends waiting on the semaphore.</div><div><br></div><div><br></div><div>So in fact, isSuspended should read something like</div><div><br></div><div>isSuspended</div><div><span style="white-space:pre-wrap">        </span>| myRunList |</div><div><span style="white-space:pre-wrap">        myRunList := </span>Processor waitingProcessesAt: priority.<br></div><div><span style="white-space:pre-wrap">        ^myList notNil and: [myList ~~ myRunList]</span><br></div><div><span style="white-space:pre-wrap"><br></span></div><div><span style="white-space:pre-wrap">except that this isn&#39;t atomic.  But it isn&#39;t the complete nonsense we have at the moment.  Here&#39;s an atomic version that answers the truth at the point that the question was asked:</span></div><div><span style="white-space:pre-wrap"><br></span></div><div><span style="white-space:pre-wrap">isSuspended</span></div><div><span style="white-space:pre-wrap">        </span><span style="white-space:pre-wrap">| myPriority |</span></div><div><span style="white-space:pre-wrap">        myPriority := priority.</span><span style="white-space:pre-wrap"><br></span></div><div><span style="white-space:pre-wrap">        ^myList</span><span style="white-space:pre-wrap"><br></span></div><div><span style="white-space:pre-wrap">        </span><span style="white-space:pre-wrap">        ifNil: [false]</span><span style="white-space:pre-wrap"><br></span></div><div><span style="white-space:pre-wrap">        </span><span style="white-space:pre-wrap">        ifNotNil: [:list| list ~~ (</span>Processor waitingProcessesAt: myPriority)]<span style="white-space:pre-wrap"><br></span></div><div><span style="white-space:pre-wrap"><br></span></div><div><span style="white-space:pre-wrap">We need tests like</span></div><div><span style="white-space:pre-wrap"><br></span></div><div><span style="white-space:pre-wrap">    self deny: Processor activeProcess isSuspended.</span></div>    self deny: ([Semaphore new wait] forkAt: Processor activePriority) isSuspended.</div><div><div><span style="white-space:pre-wrap">    self assert: </span>([Semaphore new wait] forkAt: Processor activePriority + 1) isSuspended.</div><div><br></div><div><div dir="ltr"><div><span style="font-size:small;border-collapse:separate"><div>_,,,^..^,,,_<br></div><div>best, Eliot</div></span></div></div></div>
</div></div>
<br></blockquote></div><br></div>