[comp.lang.smalltalk] Simulations in ST80

loggen@cs.eur.nl (R.P. Loggen) (03/06/90)

I have a question about a method for the class Simulation. This class
is responsible for supervising simulations. The main method is the
method 'proceed'.
The current version of this method is :

=====================================================
proceed
| eventProcess |

[self readyToContinue]
   whileFalse:[ Processor yield].
eventQueue isEmpty
   ifTrue:[^self finishUp]
   ifFalse: 
		  [eventProcess <- eventQueue removeFirst.
		   currentTime  <- eventProcess condition.
		   eventProcess resume]
=====================================================
In english :
  wait until no simulation-process is busy
  Look if there is a simulation-process waiting
  if not so : quit
  if so : resume the process and exit method.

I think that this is not a very good way of doing things...
You start up another process and return..
Isn't a better idea to first start up a proces (if available)
and the wait until this (and other simulation-processes) is/are
terminated or suspended : in pseudo code...

Look if there is a process waiting
 ifSo: remove process from queue, 
	   set current time
	   startup the process
	   wait until all sim. processes are terminated or suspended
 ifNot: finish..

In this method control to the calling object is returned after all
processes are suspended or terminated. So no small, hidden, creepy
simulation process is processing somewhere outthere....
In Smalltalk :
===========================================================

Proceed
| eventProcess |

 eventQueue isEmpty
  ifFalse:[eventProcess <- eventQueue removeFirst.
		   currentTime <- eventProcess condition.
		   eventProcess resume.
		   [self readyToContinue]
			 whileFalse:[Processor yield]]
  ifTrue:[self finishUp].

==========================================================

Please comment me on this one...I'll summarize if necessary...

                              regards,
							   Roeland Loggen


-- 
======================================================================
=    Loggen@cs.eur.nl      *  Roeland Loggen, student Informatics *  =  
=  Nothing is an Object,   *  Erasmus University, the Netherlands *  =
=    even Nothing...                                                 =