[concurrency-interest] Context-switching VS Continuation

Jean Morissette jean.morissette666 at videotron.ca
Thu Jun 9 09:40:16 EDT 2005


Hi all,
	I would be happy to have your comments on this...

First, we are building a SEDA-based framework, http://jcyclone.sf.net, which 
is designed to support massive degrees of concurrency.  Our framework is a 
little bit like a graph of executors (Stages) linked by queues.  

Actually, we are working on an innovative (or weird) continuation-based 
scheduler that eliminate context-switch.  The idea is to instrument 
user-provided classes (event handlers) in such a way that the thread context 
(call stack, etc) is saved in a continuation object when a thread encounters 
a wait(), and can be restored later.  When notify() is called on the monitor, 
a waiting continuation is put in the ready queue of the scheduler.

So, by creating as much threads as cpus, there is no context-switch at all.  
However, the cost of saving the thread context can be significant if the 
stack is very deep.  To overcome this, our scheduler use some statistiques to 
schedule threads in such a way that "continuation-switchs" occurs very 
rarely.

We believe that this design will outperform our the conventional 
"thread-pool / OS scheduler" design because we can use high-level 
informations (stages stats) that the OS scheduler don't have.  I'm very 
interested to have your opinions about this continuation-style design.

Thanks,
-Jean


More information about the Concurrency-interest mailing list