[Stackless] Coroutines vs Microthreads for Behaviors

Terry Hancock hancock at earthlink.net
Sun Jan 7 02:03:51 CET 2001

I'm implementing a "behavior" / "subsumption
architecture" system in Python, and I've been
looking into methods for running quasi-parallel
"Augmented Finite State Machines" which are
pretty much the same as lightweight processes,
as far as I can see.

I've noticed mention of both "co-routines"
and "micro-threads" related to Stackless Python,
and I wonder if this means there are different
implementations I should be looking into.

Basically I need to periodically start a large
number of separate, lightweight processes, which
process information internally.  They do not need
to communicate, except at the "cusps" between
execution cycles when the scheduler takes over,
integrates all the connecting virtual wires and
resets the routines.  The scheduler does need to
be able to kill overdue routines (i.e. if they
don't make their deadline, the scheduler kills
them and makes a note of the poor performance for
debugging purposes, but the simulation moves on).
The whole system operates at some real-time
frequency determined by the programmer.

My understanding of co-routines (from a completely
different source) is that they could do this
reasonably well, with the possible exception of
the scheduler being able to kill overdue routines.

On the other hand, threads, with all the interthread
communications and synchronization provisions
might be overkill.  Still, I was thinking that
the micro-threading module was probably the way
to go.

The assured scheduling, BTW, is the main reason
for not simply looping through the behaviors
sequentially, which would obviously be simpler
to program.

Is there any other approach I ought to be

Thanks for any opinions or comments!

Terry Hancock
hancock at earthlink.net
Stackless mailing list
Stackless at starship.python.net

More information about the Stackless mailing list