[squeak-dev] Re: Process conflict when redisplaying World

Andreas Raab andreas.raab at gmx.de
Wed May 6 17:08:15 UTC 2009


Trygve Reenskaug wrote:
> Thanks Andreas, for your very quick answer.
> Stepping was the first mechanism I tried, but the program got very 
> complex keeping track of what to do at each step. My goal is to have a 
> simple, readable program and the stepping alternative was neither simple 
> nor readable.  So I'm trying other solutions.

In that case you need to define what a "stable" state for your 
simulation is. Once you have that you can implement something where you 
pass a semaphore into the simulation that is being signaled when the 
simulation should make progress, and that the simulation waits on when 
it's in a stable state. Along the lines of:

sema := Semaphore new.
[
   sema wait. "wait for the simulation to begin"
   simulator syncSema: sema.
   simulator simulate.
] forkAt: Processor userInterruptPriority.

MyMorph>>step
   "Allow our simulation to run until it has reached stable state"
   sema signal.

Then anywhere in the simulation where it's safe to do so, just throw in 
a sema wait.

Cheers,
   - Andreas



More information about the Squeak-dev mailing list