[squeak-dev] Re: Process>>isSusended

Tobias Pape Das.Linux at gmx.de
Thu Feb 18 23:10:21 UTC 2016


Hi,
On 19.02.2016, at 00:06, Eliot Miranda <eliot.miranda at gmail.com> wrote:

> Hi Marcel,
> 
> On Thu, Feb 18, 2016 at 1:30 PM, marcel.taeumel <Marcel.Taeumel at hpi.de> wrote:
> Hi, Eliot.
> 
> Now there are no suspended processes anymore. :-/ I just grabbed a debugger
> and took its interruptedProcess. #isSuspended still returned false.
> 
> If isSuspended means is waiting on some process list other than the runnable process lists then this is what you'd expect.  For example, the background process is not suspended.  If what yu want to test for is "runnable but not running" then you need something like
> 
> isRunnable
> 	"A process is runnable if it is the active process or is on one of the runnable process lists."
> 	| myPriority |
> 	"Grab my priority now.  Even though evaluation is strictly right-to-left, accessing Processor could involve a send."
> 	myPriority := priority.
> 	^myList
> 		ifNil: [^self == Processor activeProcess]
> 		ifNotNil: [:list| list == (Processor waitingProcessesAt: myPriority)]
> 
> In my image I have all of isRunnable, isSuspended and neither (terminated) processes
> 
> | procs |
> procs := Process allInstances.
> procs size -> (procs select: [:p| p isRunnable]) size -> (procs select: [:p| p isSuspended]) size -> (procs reject: [:p| p isRunnable or: [p isSuspended]]) size 19->4->6->9
> 
> 
> So I think your issue is that you a) have no isSusoended processes; create some by e.g. opening lots of browsers so that there are background shout processes waiting on semaphores, b) collect some processes that compute something that doesn't take too long, so you've got terminated processes, and then try again.
> 
> So let's have a look at those processes above
> 
> 
> | procs full types |
> procs := Process allInstances.
> types:= {procs select: [:p| p isRunnable]. procs select: [:p| p isSuspended]. procs reject: [:p| p isRunnable or: [p isSuspended]]}.
> full := types collect: [:type| type collect: [:ea| ea -> (ea suspendedContext ifNil: ['Active or terminated'] ifNotNil: [:c| c stackOfSize: 5])]].
> full 
> 
> "isRunnable"
> {{  a Process in ProcessorScheduler class>>idleProcess->an OrderedCollection(ProcessorScheduler class>>idleProcess [] in ProcessorScheduler class>>startUp: [] in BlockClosure>>newProcess) .
>     a Process in nil->'Active or terminated'} .
> 
> "isSuspended"
> {a Process in Delay class>>handleTimerEvent->an OrderedCollection(Delay class>>handleTimerEvent Delay class>>runTimerEventLoop [] in Delay class>>startTimerEventLoop [] in BlockClosure>>newProcess) .
> a Process in [] in [] in SHTextStylerST80(SHTextStyler)>>styleInBackgroundProcess:->an OrderedCollection([] in [] in SHTextStylerST80(SHTextStyler)>>styleInBackgroundProcess: [] in BlockClosure>>newProcess) .
> a Process in EventSensor>>userInterruptWatcher->an OrderedCollection(EventSensor>>userInterruptWatcher [] in EventSensor>>installInterruptWatcher [] in BlockClosure>>newProcess) .
> a Process in [] in Delay>>wait->an OrderedCollection([] in Delay>>wait BlockClosure>>ifCurtailed: Delay>>wait [] in EventSensor>>eventTickler BlockClosure>>on:do:) .
> a Process in WeakArray class>>finalizationProcess->an OrderedCollection(WeakArray class>>finalizationProcess [] in WeakArray class>>restartFinalizationProcess [] in BlockClosure>>newProcess) .
> a Process in SmalltalkImage>>lowSpaceWatcher->an OrderedCollection(SmalltalkImage>>lowSpaceWatcher [] in SmalltalkImage>>installLowSpaceWatcher [] in BlockClosure>>newProcess) .
> "this one is the styler for the pane in which I ran the doit:"
> a Process in [] in [] in SHTextStylerST80(SHTextStyler)>>styleInBackgroundProcess:->an OrderedCollection([] in [] in SHTextStylerST80(SHTextStyler)>>styleInBackgroundProcess: [] in BlockClosure>>newProcess)} .
> 
> "neither isRunnable notr isSuspended"
> {a Process in [] in BlockClosure>>newProcess->an OrderedCollection([] in BlockClosure>>newProcess) .
> a Process in [] in BlockClosure>>newProcess->an OrderedCollection([] in BlockClosure>>newProcess) .
> a Process in nil->'Active or terminated' .
> a Process in [] in BlockClosure>>newProcess->an OrderedCollection([] in BlockClosure>>newProcess) .
> a Process in [] in BlockClosure>>newProcess->an OrderedCollection([] in BlockClosure>>newProcess) .
> a Process in [] in BlockClosure>>newProcess->an OrderedCollection([] in BlockClosure>>newProcess) .
> a Process in [] in BlockClosure>>newProcess->an OrderedCollection([] in BlockClosure>>newProcess) .
> a Process in [] in BlockClosure>>newProcess->an OrderedCollection([] in BlockClosure>>newProcess) .
> a Process in [] in BlockClosure>>newProcess->an OrderedCollection([] in BlockClosure>>newProcess)}}
> 
> 
> Hmmm, interesting.  The isRunnable and isSuspended set are exactly as I would expect.  But what are all these spawning processes?  I'll use the pointer finder to track them down.
> 
> 6 of them are styler processes that have yet to start running, so presumably in browsers I've left open but have never looked at.
> One of them was terminated before I could track it down.
> One of them is the modalProcess in an MCMergeBrowser.
> One of them is the uiProcess in a project.
> 
> So as far as I can tell the isSuspended and isRunnable definitions I mention above are fine.  Shall I commit isRunnable?

Just one thing:
I thought of 'isSuspended' meaning: 'this thing is not running, but it could eventually' not 'this thing cannot run because it is actively waiting for something'.
You see, if I call 'Processor yield' I'd expect the current process to be 'suspended', which wouldn't match your definition, as it is merely runnable…

what about isSuspended and isBlocked…?
best regards
	-tobias

> 
> 
> Best,
> Marcel
> 
> 
> 
> --
> View this message in context: http://forum.world.st/Process-isSusended-tp4878671p4878690.html
> Sent from the Squeak - Dev mailing list archive at Nabble.com.
> 
> 
> 
> 
> -- 
> _,,,^..^,,,_
> best, Eliot
> 



More information about the Squeak-dev mailing list