Stackless/microthreads merge news

Darrell darrell at dorb.com
Sat Mar 11 20:22:08 EST 2000


"Armin Steinhoff wrote:"
> That's very interesting ... is there a way to get that implementation ??
>
> We have ported Python 1.5.2 to QNX 4.25 and added a message passing module
> to it.
>

Here's a trick I used with QNX.

Send a message to another task from an interpreter. The message contains the
next step to run in the interpreter. The other task replys and unblocks the
interpreter right away leaving the interpreter free to handle other
requests. At some point the remote task completes and sends the word it was
given back to the interpreter. So the interpreter picks up where it left
off.

This kind of cooperative multitasking was nice for machine control. The time
critical components were there own task. The interpreter only provided high
level direction. It was easy to ensure the ordering of events. Normal
threads  allow one thread to get ahead of another and require
synchronization. Not bad if that's what you want as in the case of long
calculations. For those cases start another interpreter, QNX will only load
one copy of the code, so it's not as bad as it sounds.

Also since the interpreter was running in a remote box without monitor or
keyboard, a terminal app helped a lot. It interfaced via these message
snippets just like any other task.

Many people can be logged into a single threaded interpreter and think they
have it all to them self's. Like a web server with persistent state.

The interpreter wasn't Python but could have been.

--Darrell






More information about the Python-list mailing list