[Stackless] Santa concurrency problem

Richard Tew richard.m.tew at gmail.com
Tue Mar 27 09:27:57 CEST 2007


On 3/27/07, Brian Zimmer <bzimmer at ziclix.com> wrote:
> I just want to make sure I understand the ramifications of adding
> sleep() to the main thread.  If I have the following code I will be
> forced to wait until I come out of the time.sleep regardless of
> activity on the channel.  This sleep implementation works only because
> of the particular use case of the Santa problem, correct?  I can type
> all day long into stdin but the tasklet is only going to display a
> character every five seconds.

Exactly.  That implementation requires that sleeping tasklets be the only
blocking activity in the program in which it is used.

> Is there a tasklet-safe sleep that the default scheduler can handle
> appropriately?

Are you asking if there is an über-sleep which just works in any
context?  If you are, the answer is no.  There is no guarantee of how the
user is making use of Stackless.  The best we can do is give a whole
lot of examples and hope the user doesn't use them without an
understanding that they need to be adjusted to their needs and
environment.

> Also, is mixing threads and tasklets this way meant to be avoided?

Channels can safely be used for interthread communication in the manner
you did in the accompanying source code.  Of course, I am a little hazy
on this since it has been a while since I played with it, but they definitely
support interthread usage.  I should really write an example which goes
through the different channel usages to demonstrate it.

Richard.

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



More information about the Stackless mailing list