[Stackless] tasklets on threads
richard.m.tew at gmail.com
Thu Sep 8 01:43:10 CEST 2011
2011/9/8 Kristján Valur Jónsson <kristjan at ccpgames.com>:
> I just realized that there are various interesting ways to crash stackless
> with threads.
> This one is simple
> Import treading, stackless
> Def foo():
> Global task
> Task = stackless.getcurrent()
> This will crash because the other thread‘s task->cstate is NULL.
> This is fixable. But what about other cases? Tasklets that are blocked (or
> removed) when their thread exits?
> Their task->cstate->tstate will be invalid. And so, there are a number of
> things that can be done to crash them, like task.insert(), I imagine.
> Should we worry about this? Or should we simply require of the programmer
> that for safe operation, a thread should exist at least as long as all
> tasklets created on it, and leave it to the programmer to ensure?
Do we really have a choice? Is it clean to forceably kill all
tasklets belonging to a thread when it exits? i.e. raise a
TaskletThreadExit exception on them.
I seem to recall Christian saying that some tasklets could be migrated
under certain circumstances - presumably if they had not done any hard
switching. Doesn't sound very useful if some can and some can't,
unless the programmer is given a choice via a callback when the time
More information about the Stackless