[comp.sys.mac.programmer] MacApp memory mgmt with Callbacks

rdominy@kong.gsfc.nasa.gov (Robert Dominy) (03/27/91)

I'm having trouble with using callback/completion routines for
MacTCP under MacApp.  It seems that under the MacApp memory
management, it is possible that the segment in which my callback
routines are defined can be periodically unloaded.  This of course
kills the program if any such routine is invoked.

What is the proper way of telling MacApp that a Code seqment should
be resident in memory and should not be unloaded?  I tried defining
my own 'seg!' resource as described in the reference manual, but this
did not seem to help.  I was able to define the callback routines as
being in one of MacApp's resident segments (GDebug) which seemed
to work.

Thanks....

-------------------------------
Robert Dominy
NASA Goddard Space Flight Center

peirce@outpost.UUCP (Michael Peirce) (03/28/91)

In article <4637@dftsrv.gsfc.nasa.gov>, rdominy@kong.gsfc.nasa.gov (Robert Dominy) writes:
> 
> I'm having trouble with using callback/completion routines for
> MacTCP under MacApp.  It seems that under the MacApp memory
> management, it is possible that the segment in which my callback
> routines are defined can be periodically unloaded.  This of course
> kills the program if any such routine is invoked.
> 
> What is the proper way of telling MacApp that a Code seqment should
> be resident in memory and should not be unloaded?  I tried defining
> my own 'seg!' resource as described in the reference manual, but this
> did not seem to help.  I was able to define the callback routines as
> being in one of MacApp's resident segments (GDebug) which seemed
> to work.

I think you want to define a 'res!' resource, rather than (or in addition
to?) a 'seg!' resource for resident segements.

You could also just use one of the predefined resident segments like
MARes ({$S MARes}), though your choice of GDebug might cause problems if 
you build a non-debug version.

-- michael

--  Michael Peirce         --   outpost!peirce@claris.com
--  Peirce Software        --   Suite 301, 719 Hibiscus Place
--  Macintosh Programming  --   San Jose, California 95117
--           & Consulting  --   (408) 244-6554, AppleLink: PEIRCE

ph@ssd.kodak.com (Pete Hoch) (03/28/91)

<4637@dftsrv.gsfc.nasa.gov> rdominy@kong.gsfc.nasa.gov (Robert Dominy) writes:

>What is the proper way of telling MacApp that a Code seqment should
>be resident in memory and should not be unloaded?  I tried defining

In C++ put a "#pragma segment ares" line before the routine you want
to stay resident.  I forget the format for Pascal but it exsists.

Pete

-- 
Pete Hoch                         | ..somewhere..!kodak!ssd!bashow!ph   ..or..
Color Systems ISPD. 3/65/RL       | ph@ekcolorlink.ssd.kodak.com        ..or..
Eastman Kodak Co. 	          | ph@bashow.ssd.kodak.com
Rochester, NY 14650-1805          | 716-722-3285