[plt-scheme] Creating a suspended thread

From: Marc Feeley (feeley at iro.umontreal.ca)
Date: Mon Apr 13 23:27:38 EDT 2009

On 13-Apr-09, at 9:18 PM, Robby Findler wrote:

> On Mon, Apr 13, 2009 at 8:15 PM, Matthias Felleisen
> <matthias at ccs.neu.edu> wrote:
>> On Apr 13, 2009, at 8:44 PM, Marc Feeley wrote:
>>> Note that this separation of thread creation and activation is not  
>>> novel
>>> (indeed Java is a well known instance of a system supporting this).
>> I understand that. I just don't think the reasoning is convincing
> It seems easy to implement initially suspended threads (indeed Matthew
> showed the code a moment ago), no?

The problem of conflating thread creation and activation is no  
different than the problem of conflating function creation and  
variable definition (which Scheme chose not to conflate).  You can  
simulate anonymous functions with named functions by using a temporary  
name.  But you pay a price in program clarity (elegance?) and in run  
time cost (unless you have a Sufficiently Smart(tm) compiler).

The "thread/suspend" procedure submitted by Matthew runs about 5%  
slower than the "thread" procedure alone (on MzScheme v4.1 + Intel Mac  
OS X).  So the additional semaphore operations don't seem to add much  
of an overhead.  But that is because thread creation in MzScheme is  
slow in comparison to the semaphore operations (about 45 microseconds  
per thread creation + termination).  In a system with faster thread  
creation operations the overhead becomes quite noticeable (Gambit is  
about 45 times faster, i.e. one microsecond per thread creation +  


Posted on the users mailing list.