[Stackless] Coroutines vs Microthreads for Behaviors
Christian Tismer
tismer at tismer.com
Mon Jan 8 20:46:04 CET 2001
Terry Hancock wrote:
>
> Hi,
> 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.
Not really. They aren't that much different.
> 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.
Just have a look into the microthread module whether
it suits your needs.
The extra payload for microthreads vs. coroutines
is not so high. There is a little more switching
overhead for microthreads, since they involve a little
scheduler function instead of switching directly like
coroutines, but this difference will be neglectible
quite soon, when this functionality is implemented in C.
> 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
> considering?
For me, it looks most natural to use the uthreads here.
ciao - chris
--
Christian Tismer :^) <mailto:tismer at tismer.com>
Mission Impossible 5oftware : Have a break! Take a ride on Python's
Kaunstr. 26 : *Starship* http://starship.python.net
14163 Berlin : PGP key -> http://wwwkeys.pgp.net
PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF
where do you want to jump today? http://www.stackless.com
_______________________________________________
Stackless mailing list
Stackless at starship.python.net
http://starship.python.net/mailman/listinfo/stackless
More information about the Stackless
mailing list