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

Re: exception systems

|   Date: Thu, 18 Apr 1996 15:03:02 -0400
|   From: Olin Shivers <shivers@lambda.ai.mit.edu>
|   Cc: gjr@martigny.ai.mit.edu, will@ccs.neu.edu, rrrs-authors@mc.lcs.mit.edu
|   Reply-To: shivers@ai.mit.edu

|   My take on async signals, such as clock timers and so forth, is that
|   they shouldn't necessarily be presented in terms of a premptive
|   mechanism like interrupts. This commits you to a serial implementation,
|   since preemption implies mutex -- when the handler is running, the
|   main thread is not.
|   In a multi-threaded model, you can afford to let threads block and
|   synchronously wait for signals from other agents. I find this to
|   be a much more appealing model.
|   You can always *implement* it, on a serial machine, with preemptive
|   interrupts. But you can *also* implement it, on a multiprocessor,
|   with a parallel implementation. This is good.
|   Models shouldn't capture details that are restrictive to a particular
|   implementation. Interrupts are a bad model.
|       -Olin

Your CMU/Mach bias is showing through...

I think you are assuming that you need a full context switch when an
interrupt arrives.  This is unnecessary, and the point of my previous

Both models are equivalent (easy to implement on each other), and the
interrupt model does not presupose any particular overhead over the
thread model.  In fact, the thread model is, to my knowledge, always
implemented on top of a low-overhead interrupt mechanism.

To implement the thread model that you like efficiently on top of
interrupts, the interrupt handler would merely unblock the thread
blocked on delivery and immediately _return_ to the suspended thread.
The ordinary scheduler would then schedule the thread for execution at
the next convenient/possible moment.

One of the beauties of using Scheme for interrupt handling is that a
closure is an incredibly effective mini-context.  The interrupt
handler can close over the appropriate mutex structure to unblock the
thread and the only thing it would do was to release the mutex and