Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!gem.mps.ohio-state.edu!sunybcs!sbcs!vallon From: vallon@sbcs.sunysb.edu (Justin Vallon) Newsgroups: comp.sys.mac.programmer Subject: Re: Segmentation (was Re: ARRGH (Strings and things)) Message-ID: <3813@sbcs.sunysb.edu> Date: 2 Nov 89 20:18:58 GMT References: <16004@netnews.upenn.edu> <8835@hoptoad.uucp> <16420@dartvax.Dartmouth.EDU> <8852@hoptoad.uucp> <14386@well.UUCP> <8878@hoptoad.uucp> <1989Nov2.053139.23967@agate.berkeley.edu> Sender: news@sbcs.sunysb.edu Reply-To: vallon@sblw.UUCP (Justin Vallon) Organization: State University of New York at Stony Brook Lines: 38 In article <1989Nov2.053139.23967@agate.berkeley.edu> lippin@math.berkeley.edu writes: >Recently tim@hoptoad.UUCP (Tim Maroney) wrote: >>You also ignored the function pointer issue. I received a letter from >>a person at Apple that I respect and who is usually right, but not this >>time. He says that you should put all function-pointer fetching >>routines into the main code segment: that way, they will be jump table >>pointers. This may work fine for code that uses one or two function >>pointers and calls them all itself. However, just imagine passing a >>function pointer into the jump table to the vertical retrace manager or >>as a completion routine to the file manager. Can you say "intermittent >>crash when A5 is not CurrentA5"? I knew you could. > >Both of you got this one wrong. Any development system worth its >salt, and certainly any I've used, will create function pointers as >pointers into the jump table, precisely so that they're always valid. >They're truly absolute pointers, so they don't care one whit about >CurrentA5 (although your code might; that's the well-known gotcha of >interrupt tasks, and has established solutions.) > I seem to sense some confusion here. I think you two are arguing about two different things. Tim said "put all function-pointer FETCHING routines into the main code segment". I think this is a little wrong. I think person at Apple said, or meant to say, that you should put any function that will be referenced by a function-pointer into the main segment. When the main segment is loaded (when you are launched), all main-segment jump-table entries will be set at the time of _LoadSeg. Remember that when _LoadSeg is called, ALL jt entries that reference that segment are updated to a single JMP to the address of the routine in the locked code segment. Since you never UnloadSeg(main-seg), these jt entries will never require a LoadSeg, or A5 to get to your routine in the always- loaded main segment. --------------------------------------------------------------------------- -Justin vallon@sbcs.sunysb.edu ---------------------------------------------------------------------------