[Stackless] [Uuu-devel] python internal hacking: multitasking, interrupts, and the like

Jeff Senn senn at maya.com
Mon Apr 24 16:02:49 CEST 2006


[Removed python-list from reply...]

On Aug 30, 2004, at 8:08 PM, Phil Frost wrote:
> ...
> To that end I've decided to get a new scheduler, and I want to do  
> it in
> Python. There are some things to consider:
> ...
> The problem with Stackless is that I can't find any information on it.
> I've made inquiries to their mailing list about how tasklets are
> scheduled and received no response. Perhaps someone knowledgeable has
> subscribed since I last asked this question. If so, please share your
> knowledge.

Hello Phil-

There is not a ton of interest among the "stackless" (heh), in the
preemptive scheduling aspects of using tasklets... There has been
more discussion on the co-routine/continuation/messaging aspects.   
However it is
definitely possible to do what you want to do.  In fact, a few years
ago we did a very similar project that turned stackless into the  
"kernel"
for an embedded ARM processor (though much like you intend, there
was actually the most tiny linux-ish kernel running one single python  
process).
That project did not progress beyond a proof-of-concept prototype -  
however I can strongly
urge you to pursue the stackless path... it was VERY easy to bolt  
something
together.

Take a look here: http://www.stackless.com/wiki/Scheduling

And note, that if you're willing to dig into the code a bit
(.../Python/ceval.c, .../Stackless/scheduling.c) it would not be hard
to implement whatever scheduler algorithm you like in C
(though I would suggest prototyping in Python first and maybe you'll
decide not to do this for a long time...).
{Oh: I should note: I haven't looked at the newest ports 2.4.3+ ...
I hope the methodology hasn't changed much}

The "hard part" will be "device drivers", in our project we basically  
only
had one...since our processor was in a system where all other devices  
had
separate processors and a messaging interface to the "main" one.  So  
there
was just a polling routine as part of the scheduler that converted  
"raw" message
buffers to/from Python objects; and "I/O" was scheduled along with  
everything
else.

The best part of doing our project this way was that debugging was  
relatively
easy compared to the traditional multiply-threaded hardware interrupt  
model...
being able to just tune up/down the scheduling quanta and being able  
to watch
the scheduler switch in gdb was a real joy :-)

 > write a scheduler with it. I think if I were able to attach a python
 > routine to an interrupt handler, I could do with a minimal amount of
 > supporting C and assembly. However, I'm not sure how I can do  
this. The
 > problem is the infamous GIL; I don't know how I can acquire the lock

Say more about this... and maybe we can give you some help... what sort
of interrupts do you mean?

-Jas


  	


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



More information about the Stackless mailing list