[Stackless] Algorithm for Stackless Scheduler

Arnar Birgisson arnarbi at gmail.com
Tue Nov 11 17:51:15 CET 2008


Thank you Jeff,

On Tue, Nov 11, 2008 at 17:26, Jeff Senn <senn at maya.com> wrote:
> Here... I'll contribute a try-to-be-brief summary (to the best of my
> recollection):
>
> There is a special: the "main" tasklet.
> There is a doubly-linked (circular) list of "runnable" tasklets.
> The head of the runnables is the "current" tasklet  (unless "main" is
> current...)
>
> Calling tasklet.insert() inserts (or re-inserts) at the END of the
> runnables.
> Calling tasklet.remove() removes from runnables.
> Calling stackless.schedule() rotates the head of runnables to the NEXT one
> after current
>  and switches to it.
>
> Calling chan.receive/send() can remove the current tasklet from runnables
>  if nothing is "waiting at the other end" (the NEXT tasklet in runnables
>  is continued).
>
>  OR (depending on the channel preference) continue in the caller
>  (inserting the sender/receiver at the "other end" onto runnables)
>  or rotate the head of runnables to the sender/receiver and pick up there.

If you have time, I think it would be very useful to describe this
(perhaps with pseudo-code) on the scheduler wiki page:
http://www.stackless.com/wiki/Scheduling

Channel preferences are particularly hard to understand by newcomers
given the current documentation. I think this might fix that problem.

Although, I found today that reading the code is helpful. I had no
idea that channels can act as iterators or channel.send_sequence(...).

cheers,
Arnar




More information about the Stackless mailing list