[comp.sys.mac.programmer] Interrupt Routines and the Segment Loader

nick@cs.edinburgh.ac.uk (Nick Rothwell) (11/06/90)

I'm about to bring my MIDI Manager code up-to-date, using THINK C 4.0 and
the TCL. My understanding is that the following is secure:

static pascal void someRandomHandler(...)
{
...
}

void CMIDI::IMIDI()
{
   ...
    SomeMidiManagerInstaller(&someRandomHandler);
}

Now, about the segment loader. My reading of Inside Mac II suggests that
segments, once loaded, aren't unloaded unless you call UnloadSeg(procptr).
So, this is safe, since the handler is in the same file (hence, segment)
as the installer, and doesn't go through the jump table.
Is this right? I had a poke around inside a TCL application:
all the code segments are initially purgeable in the application itself
(all except CODE 1, I think), but once running, they're all loaded and
locked (but not made unpurgeable).

Might I come to grief, or do I have nothing to worry about?

Presumably, installing an *external* interrupt routine from another
segment is Bad News - if that segment's never been loaded, then you're
installing something which will dispatch through the jump table and
call the segment loader at interrupt time; and even if the seg is loaded,
there's presumably a (small) performance hit...


-- 
Nick Rothwell,	Laboratory for Foundations of Computer Science, Edinburgh.
		nick@lfcs.ed.ac.uk    <Atlantic Ocean>!mcsun!ukc!lfcs!nick
~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~
 "Now remember - and this is most important - you must think in Russian."