[Stackless-dev] More thoughts on Greenlets

Christian Tismer tismer at stackless.com
Tue Mar 16 16:49:32 CET 2004


Hi Armin,

you might have seen my lengthy phantasies about greenlets.
Btw.: I talked about "placable" greenlets, but I really
meant "placeable" which is a huge difference :-)

I haven't tried the module at all, but reading was very
interesting. There is one place where I stumbled a little
bit, and I guess it can be simplified:

In g_initialstub you claim a certain piece of stack and
jump off to the caller. The comment reads that you return
twice. As stated elsewhere, I propose *not* to allocate
the stack position on greenlet creation, but to do that
when calling.
I think, when a greenlet is created, it only saves the
function to be called later and returns.
When it is activated the first time, it is simply run in the
current caller's stack and records its stack_start.
Then, there are two possibilities:

a) It does something, leaving state on the stack and jumps
    off to another greenlet. In this case it is bound to the
    piece of stack that it claims, and things work like
    you did it.

b) It does something, stores all of its state in some structure,
    and then jumps to another greenlet without denoting its
    stack area. This means the greenlet is placeable again
    and can be run from anywhere without performing a jump.

Does this create new problems?
I see that you want to build this parent chain in the
initialisation of the greenlet, to have a list which is ordered
by stack address. But I think if this is done on the
first activation, the condition of an ordered stack image
still is fulfilled and we get much more flexibility.

Pleae correct me if I'm wrong -- ciao - chris
-- 
Christian Tismer             :^)   <mailto:tismer at stackless.com>
Mission Impossible 5oftware  :     Have a break! Take a ride on Python's
Johannes-Niemeyer-Weg 9a     :    *Starship* http://starship.python.net/
14109 Berlin                 :     PGP key -> http://wwwkeys.pgp.net/
work +49 30 89 09 53 34  home +49 30 802 86 56  mobile +49 173 24 18 776
PGP 0x57F3BF04       9064 F4E1 D754 C2FF 1619  305B C09C 5A3B 57F3 BF04
      whom do you want to sponsor today?   http://www.stackless.com/



_______________________________________________
Stackless-dev mailing list
Stackless-dev at stackless.com
http://www.stackless.com/mailman/listinfo/stackless-dev



More information about the Stackless-dev mailing list