[Stackless] Scheduling Examples, Problems, Solutions, and Questions

Andrew Francis andrewfr_ice at yahoo.com
Tue Mar 21 20:14:22 CET 2006

Hello Joachim:

--- Joachim König-Baltes
<joachim.koenig-baltes at emesgarten.de> wrote:

> IMO the fact that stackless channels have no
> internal buffer but directly block on send when
>there's no receiver enlarges the
> probability for starvation / deadlock. 

I believe the blocking provides two of the deadlock 
conditions -

1. Hold and Wait
2. No pre-emption

I think 1. occures if tasklet A is waiting on a
channel, yet tasklet A is also the only tasklet
capable of performing an action on a second channel it
"owns" and has other waiting tasklets. 

if one of these waiting tasklets "own" a channel that
the tasklet A is blocked on, then you get 3. circular

The cooperative nature of the tasklets provides the
"mutual exclusion."

It is one of my goals to exactly understand how dead
lock occurs in Stackless, and come up with techniques
to detect it/avoid it. One of these days, I will post
the example I initially showed in the Wiki, and
explain why it dead-locked. One of my problems is that
I drew the graph wrong and did not see the deadlock.
Asgeir pointed it out. I want to be able to provide an
explanation in terms of deadlock detection

>With a buffer (like in Asgeir's Queue
>implementation) you can go on and write to
> other channels too or read from them thus avoiding
> premature blocking.

I believe you will get some blocking on Asgeir's queue
if the queue is empty....

I believe the mechanism you are thinking of is a
mailbox. Mailboxes would eliminate the "hold and wait"
condition. I recall seeing a e-mail in one of the
Python groups about how asynchronous communications
using queues is the way to go. Andrew Hunt in "The
Pragmatic Programmer" discusses this as well.

> It would have been nice, if the channels tried to be
> compatible (to a certain degree) to the standard
>Queue modules Queue

Offhand, I don't think this is hard to do. I think it
is a case of overriding the Rlock objects and
replacing them with Stackless equivalents. Let me look
more closely at this.

> I think, channels with buffers ease tasklet
> programming.

Yes, I agree.


Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 

Stackless mailing list
Stackless at stackless.com

More information about the Stackless mailing list