[Stackless] Does stackless only work with pure Python codes?

Christian Tismer tismer at stackless.com
Fri Nov 26 16:26:57 CET 2004


Limin Fu wrote:
> Hello everybody,
> 
> Using stackless in python to simulate multithread
> sounds interesting. But I wonder what will happen with
> stackless if a python program will use loaded C
> modules, since the C module can not be divided into
> tiny task by Python codes.

If a C module is running, Stackless can't do anything.
If the C module calls back into Python and executes
bytecodes, then Stackless is active, again, and it is
possible to switch tasklets, even if there is still
an active C function on the C stack. In this situation,
Stackless modifies the C stack to perform switches.
This way of switching has been the one and only in
Stackless 2.0. In 3.0, I try to avoid fiddling the
C stack at all, because it is much faster. But for
cases like this, it is a powerful technique.

Again to your question: If a C extension happens
to stay in C code for a long time, then we cannot
switch during this time. It would be easy to modify
the extension a bit and make it run a few bytecodes
from time to time, or have it explicitly run the
stackless "schedule" function in order to give up
its time slice.

ciao - chris

-- 
Christian Tismer             :^)   <mailto:tismer at stackless.com>
tismerysoft GmbH             :     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 802 86 56  mobile +49 173 24 18 776  fax +49 30 80 90 57 05
PGP 0x57F3BF04       9064 F4E1 D754 C2FF 1619  305B C09C 5A3B 57F3 BF04
      whom do you want to sponsor today?   http://www.stackless.com/

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



More information about the Stackless mailing list