[squeak-dev] Process>>isSusended

Eliot Miranda eliot.miranda at gmail.com
Thu Feb 18 21:22:28 UTC 2016

Hi All,

   we have a serious misunderstanding in current versions of Squeak's and
Pharo's Process>>isSuspended.

Squeak's version reads

^myList isNil

Pharo's reads

^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

So in fact, isSuspended should read something like

| 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:

| myPriority |
myPriority := priority.
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)
self assert: ([Semaphore new wait] forkAt: Processor activePriority + 1)

best, Eliot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20160218/e1a573c1/attachment.htm

More information about the Squeak-dev mailing list