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

DYNAMIC-WIND vs. multi-processing



   Date: Tue, 11 May 93 10:16:09 -0400
   From: Gerald Jay Sussman <gjs@martigny.ai.mit.edu>

   (sorry, I am a loser!)

I'll say.

Seriously though, the reason you wanted to use DYNAMIC-WIND to
implement fluid variables in Scheme-81 is that you wanted fluid
variables to actually be implemented as ordinary lexical variables.
In the operating system that I wrote in Scheme, one uses a distinct
syntax to access the value of a fluid "variables", specifically the
(FLUID x) of the Revised Report.  With this change, task switching is
accomplished by simply changing the continuation and fluid environment
registers.  CWCC isn't used for task switching; instead there is a
lower-level operator that is only used internally to the scheduler.
DYNAMIC-WIND is supported, but the windings and unwindings only happen
when the procedures delivered by CWCC are called, not on task
switching.  DYNAMIC-WIND and CWCC have their place, but only within
individual tasks.

Note that this generalizes nicely to the case of multiprocessing (i.e.
multiple processors), whereas DYNAMIC-WIND doesn't: each processor can
easily have its own continuation and fluid environment registers.

The price is that you have to decide ahead of time which variables are
going to be fluid, and you have to write (fluid x) instead of x.
Personally I find this acceptable, and the operating system seems to
work pretty well.

If you believe, as Mr. Jaffer apparently does, that it must be
possible to write a scheduler in portable Scheme, then I would tend to
agree that the low-level non-winding version of CWCC is necessary.
I'm not sure I buy that premise, however.  It seems pretty useless to
have tasks without pre-emption; and if we do adopt pre-emption in some
form, then I think chaos would ensue unless without a standard
interface to the scheduler -- in which case, we should just adopt a
scheduler, not the low-level primitives that the implementation of a
scheduler would need.

Jonathan