Controller loops

Lex Spoon lex at cc.gatech.edu
Sun Sep 6 07:55:06 UTC 1998


John Maloney posted a great summary of this issue a couple of months
ago (appended).  After reading it I ran out and spent a few hours
playing with the system, and here's what I came up with.

In Morphic, it's *extremely* easy: just add a delay in
WorldMorph.doOneCycle.

In MVC, it's not so simple: there are busy loops all over the place.
It's generally assumed that everything other than the current
activity, is sitting static.  In addition to Controller.controlLoop,
there are seperate loops for menus, scrolling, resizing various
things, and others.

I've stuck a stab at this of my own at:

	http://www.cc.gatech.edu/~lex/squeak/www0.2/governedPolling.cs

It handles all of Morphic, plus most of the cases in MVC where the
mouse button isn't being held down.

Emperically, it seems pretty good--load meters goes down to absolutely
nothing when the system is idle, and if you leave it alone for a while
and do other memory intensive tasks, much of the Squeak process will
even get paged out to disk.  I bet you could even play a full-speed
game of Quake now with Squeak running in the background.  And does the
world get any better than nailguns and objects, existing side by side
and in "peace"?

Lex





vuletich at ar.ibm.com writes:
 > 
 > 
 > 
 > 
 > To:   squeak at cs.uiuc.edu
 > cc:
 > 
 > From:
 > 
 > 
 > 
 > Hello everybody.
 > 
 > We know that Squeak uses all the available CPU time even when it is not
 > doing anything.
 > I have seen that in Squeak there is a background process that runs:
 > ---------------------------------------------------------
 > ProcessorScheduler>>idleProcess
 >      "A default background process which is invisible."
 >      [true] whileTrue:
 >           [self relinquishProcessorForMicroseconds: 1000].
 > ---------------------------------------------------------
 > But this process is never executed because there is always a higher
 > priority Controller
 > process running. In the method:
 > ------------------------------------------------------
 > Controller>>controlLoop
 >      "Sent by Controller|startUp as part of the standard control sequence.
 >      Controller|controlLoop sends the message Controller|isControlActive to
 >  test
 >      for loop termination. As long as true is returned, the loop continues.
 > 
 >      When false is returned, the loop ends. Each time through the loop, the
 > 
 >      message Controller|controlActivity is sent."
 > 
 >      [self isControlActive] whileTrue: [self controlActivity. Processor
 > yield]
 > -------------------------------------------------------
 > the Processor yield can be changed for (Delay forMilliseconds:50) wait.
 > This makes the
 > MVC controllers poll for activity no more than 20 times a second, what is
 > perfectly enough.
 > 
 > I found that this frees almost all the processor time to other programs in
 > a multitasking OS.
 > All that is needed is to have the ioRelinquishProcessorForMicroseconds()
 > function in the
 > VM properly implemented. I tried it and works OK in Windows and OS/2
 > versions of Squeak.
 > The same should be done in ScrollController>>scroll.
 > 
 > It can also be done in MorphWorldController >>controlLoop, but Morphic
 > prefers to to have
 > its step intervals as short as possible.
 > 
 > Does this modification deserve to be in the base image?
 > 
 > Juan Manuel Vuletich
 > jvuletic at dc.uba.ar
 > 
 > 





More information about the Squeak-dev mailing list