[Vm-dev] Process>>isSusended

Henrik Sperre Johansen henrik.s.johansen at veloxit.no
Fri Feb 19 00:04:36 UTC 2016


This is not the definition of suspended that the fallback code in Process
>> #suspend uses.
By its definition, when suspended, a Process is removed from all running
queues, and there's no chance it will run again before being explicitly
resume'd. Does the primitive work differently?

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'ed,
or do we need a #trueActiveProcess as well?

Cheers,
Henry

P.S. after the change to use effectiveProcess, Processor activeProcess
should actually answer true when being debugged, no?

On Thu, Feb 18, 2016 at 10:22 PM, Eliot Miranda <eliot.miranda at gmail.com>
wrote:

>
> Hi All,
>
>    we have a serious misunderstanding in current versions of Squeak's and
> Pharo's Process>>isSuspended.
>
> Squeak's version reads
>
> isSuspended
> ^myList isNil
>
> Pharo's reads
>
> isSuspended
> ^myList isNil or: [ myList isEmpty ]
>
> Process'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's myList is always nil, so Squeak's and
> Pharo's are both wrong for the active process.
>
> Processor activeProcess isSuspended => true (!!!)
>
> 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.
>
> Processor waitingProcessesAt: Processor activePriority => a LinkedList()
> Processor waitingProcessesAt: Processor lowestPriority => a LinkedList(a
> Process in ProcessorScheduler class>>idleProcess)
>
> Here's a couple of illustrative examples:
>
> [Semaphore new wait] fork suspendingList
> => a LinkedList(a Process in [] in BlockClosure>>newProcess)
>
> ([Semaphore new wait] forkAt: Processor activePriority + 1) suspendingList
> => a Semaphore(a Process in [] in UndefinedObject>>DoIt)
>
> In the first example above the new process isn't running yet.  It's
> runnable but hasn't got a chance to run because the active process that
> created it is still running.  So the process'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.
>
>
> So in fact, isSuspended should read something like
>
> isSuspended
> | myRunList |
> myRunList := Processor waitingProcessesAt: priority.
> ^myList notNil and: [myList ~~ myRunList]
>
> except that this isn't atomic. But it isn't the complete nonsense we have
> at the moment. Here's an atomic version that answers the truth at the point
> that the question was asked:
>
> isSuspended
> | myPriority |
> myPriority := priority.
> ^myList
> ifNil: [false]
> ifNotNil: [:list| list ~~ (Processor waitingProcessesAt: myPriority)]
>
> We need tests like
>
> self deny: Processor activeProcess isSuspended.
>     self deny: ([Semaphore new wait] forkAt: Processor activePriority)
> isSuspended.
> self assert: ([Semaphore new wait] forkAt: Processor activePriority + 1)
> isSuspended.
>
> _,,,^..^,,,_
> best, Eliot
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20160219/ebe697f1/attachment.htm


More information about the Vm-dev mailing list