[plt-scheme] Creating a suspended thread

From: Marc Feeley (feeley at iro.umontreal.ca)
Date: Mon Apr 13 20:44:28 EDT 2009

On 13-Apr-09, at 4:43 PM, Matthias Felleisen wrote:

>
> Marc,
>
> local comment: I don't understand why you lock the done-mutex twice.
>

Matthew explained it well.

> global comment: I'd program this kind of situation with cml-style  
> sync primitives (available in PLT Scheme) not with mutexes and an  
> imperative style.

That's also how I would do it in Gambit with mailboxes or vector ports  
(a FIFO structure), but that is beside my point.  You can't remove  
mutual recursion in all cases.  The problem is very similar to the  
implementation of mutually recursive closures (defined with letrec for  
example).  The closures C1 and C2 have to be created first, but they  
aren't yet runnable because C1 has to be initialized with a reference  
to C2 and vice-versa.

Note that this separation of thread creation and activation is not  
novel (indeed Java is a well known instance of a system supporting  
this).

Marc



Posted on the users mailing list.