[plt-scheme] Threading vs. System Threads

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Wed Feb 12 15:21:47 EST 2003

> > > At Wed, 12 Feb 2003 11:10:59 -0600, Robert Bruce Findler wrote:
> > > > How do you handle killing of threads? That is, in the face of
> > > > custodian-shutdown-all or kill-thread, can messages appear multiple
> > > > times or can internal queues get put into bad states (deadlock)?

:) Since Robby knows what I've been working on, I think he knows the
answer to the second question. At least, he knows that I claim the
answer must be "yes" for MzScheme threads.

At Wed, 12 Feb 2003 14:49:35 -0500 (EST), Paul Graunke wrote:
> If message passing is such a widespread, useful means of communicating between
> threads (Erlang stuff, the Web server, DrScheme's REPL, the Stepper?) then
> we should really have a mechanism that works well with custodians.  Maybe
> there is some clever way to use call-in-nested-thread to make a thread
> that won't die do the queue manipulation. 

That only works if you have access to a super-custodian under which all
other programs run. In other words, you have to extend the OS for every
new kind of synchonization abstraction.

"OS" here doesn't have to mean "MzScheme". If you build a new layer on
top of MzScheme and run all programs on top of the new layer, that's
"extending the OS". Mere libraries don't have this privilege. But we'd
like to implement, for example, kill-safe channels as a library.

I'm fairly certain that MzScheme v203.4 doesn't support such a library,
no matter how clever the implementor. This problem has bothered me for
a long time, but I think I've finally arrived at a solution. If all
goes well, v203.5 will include a small addition that enables kill-safe
abstractions without sacificing any of MzScheme's existing guarantees
for termination and isolation.


Posted on the users mailing list.