[PEAK] Task containment and isolation

Richard Tew richard.m.tew at gmail.com
Sun Jul 29 18:20:01 EDT 2007


On 7/28/07, Phillip J. Eby <pje at telecommunity.com> wrote:
> Assuming that I make the Trellis automatically do the context
> switching (which I plan to, after Contextual is ready for release),
> then Trellis rules and tasks will always run in the same context as
> they were created in, regardless of when/where/how they are called --
> with or without greenlets or stackless.
>
> (Note: I am assuming that stackless tasks and greenlets can only be
> run in the thread that created them; i.e., that you can't
> context-switch across threads.)

I don't know much about Contextual, so I can't address this.  But I
can perhaps give enough information about what Stackless does and can
do, that it can be answered.

Both Stackless and Greenlets are based on the same functionality.  The
shifting of portions of the thread stack.  So they are both directly
linked to the thread they are created within.  Greenlets aren't much
more than that and a co-routine like wrapper.  But Stackless is a
framework built up around this which adds much more.

It is possible to shift a tasklet created on one thread to another by
pickling it and unpickling it on the target thread.

It is also possible to communicate between tasklets on different
threads using Stackless channels.  That is, tasklets on one thread can
be waiting on a channel and can be directly awakened from the other
thread, where tasklets have access to a reference to it.  In theory
this is very useful.. but in practice, it is not yet thread safe and
has bugs.  While Stackless has support for running schedulers on
threads other than the main one, this was disabled as it was not
tested.  We enabled it, and it is now bug free, but we still need to
debug the interthread channel usage.

Anyway, hope this helps,
Richard.



More information about the PEAK mailing list