[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Preemption, Persistence, and Mobility

Matthias Felleisen [mailto:matthias@ccs.neu.edu] wrote:
> If you have continuations in your language, you can fake threads 
> easily. See the PLT Scheme code below. Now you can experiment with 
> your thread interface. 

Is this really the right thing to do? Implementing threads with 
continuations creates many hassles when trying to explain how 
language threads interact with OS threads and blocking operations.

For the toy language I am writing, I am including both continuations
and threads. This has simplified the documentation a lot, because a
simple mental model like "threads are first-class processors, and
continuations are first-class stacks[*]" can make almost all of the
language's behavior immediately apparent. There are as many active
continations as there are threads, and a call to a blocking operation
will block the thread, and everything just seems to work. 

I don't know if this theoretically a good idea, but anything that 
simplifies the documentation that much has to have something going 
for it. 

[*] I don't actually have a stack, since I'm allocating activation 
records on the heap, but you know what I mean. 

Neel Krishnaswami