[comp.sys.mac.programmer] How can I keep my application memory resident ???

nugteren@pttrnl.nl (10/26/90)

I have written a trackball driver (in Lightspeed C) for the MacII that allows 
connection of a MSDOS trackball to the serial port of the Mac. It works fine as
an application, but now I want to put it in the background as an interrupt
handler. I thought the easiest way to do this is to build it on the ROM serial
driver, use asynchronous calls and specify a routine in my program as the
completion routine. I already tried this and it works very well as long as my
program is active (which means I have to put a "while(1){}" at the end of my
main!!). As soon as the Mac leaves my main() it throws the program away.

So what the problem really boils down to is:How can I keep my program resident?

I would greatly appreciate any tips or advice,

Nils  

oster@well.sf.ca.us (David Phillip Oster) (10/28/90)

Keeping your driver permananently resident is covered in the article:
"Writing Device Drivers in C++" in issue 4 of d e v e l o p magazine.
The basic idea is, you search the unit table looking for a free slot,
renumber your DRVR resource to that number, do an OpenDriver(), followed
by a DetachResource(), you also set the resLock, resSysHeap bits in the
DRVR resource.

-- 
-- David Phillip Oster - Note new signature. Old one has gone Bye Bye.
-- oster@well.sf.ca.us = {backbone}!well!oster

kempkec@ure.CS.ORST.EDU (Christopher Kempke) (10/31/90)

In article <56297.27285b80@pttrnl.nl> nugteren@pttrnl.nl writes:
>So what the problem really boils down to is:How can I keep my program resident?
>Nils  

I'm just guessing, but try setting the attributes on the CODE resource to
PRELOAD and LOCKED.  If you wrote this in THINK (whatever), there's an
option in the compiler to do this, otherwise I think it required ResEdit.
I think this makes it impossible for even the dread Multifinder to dispose
of your application's code segment.  Again, I may be completely misunderstandingthe problem, too.

	-Chris