Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!gem.mps.ohio-state.edu!tut.cis.ohio-state.edu!ucbvax!agate!spam!lippin From: lippin@spam.berkeley.edu (The Apathist) Newsgroups: comp.sys.mac.programmer Subject: Re: Segmentation (was Re: ARRGH (Strings and things)) Message-ID: <1989Nov2.053139.23967@agate.berkeley.edu> Date: 2 Nov 89 05:31:39 GMT References: <16004@netnews.upenn.edu> <8835@hoptoad.uucp> <16420@dartvax.Dartmouth.EDU> <8852@hoptoad.uucp> <14386@well.UUCP> <8878@hoptoad.uucp> Sender: usenet@agate.berkeley.edu (USENET Administrator;;;;ZU44) Reply-To: lippin@math.berkeley.edu Organization: Authorized Service, Incorporated Lines: 61 Recently tim@hoptoad.UUCP (Tim Maroney) wrote: >And sure, you can move things into smaller partitions this way, as long >as you don't care about certain minor facts like keeping to the >interface guidelines. User operations are supposed to begin taking >effect instantaneously. If they require fetching in a large resource >from the application file, then they are anything but instantaneous. Remember, those segments aren't getting swapped out unless you needed the memory for something else. When your user is pushing the program to where this would matter, the difference between unloading and not unloading is the difference between running slowly and not running at all. I think it's clear which one the user wants. >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.) [user-confusion caused by bugs that don't happen deleted] >I prefer instant response and program reliability, as well as the >ability to use function pointers freely in my code. There are really >very few people who need to use more than two or three programs in >conjunction with the Finder at once, and those people can get SIMMs >pretty cheap these days. Real RAM hogs like MPW Shell and FullWrite >may need to use it, but my programs rarely get over 250K. Wow! You make it sound like having teeth pulled! It's not so difficult as all that. Tom's three easy rules to a long and happy life using UnloadSeg: 1. Put the trap glue in your main segment. 2. Put your low memory emergency code in your main segment. 3. Put your main event loop in your main segment, and have it call UnloadSeg on all other segments, often. Clever programmers can improve somewhat on this, depending on the structure of their particular programs. But this will work well, and your users would appreciate it, if somebody explained the difference to them. After all, this is the computer for the rest of them. --Tom Lippincott lippin@math.berkeley.edu "You have no power here! Now begone, before someone drops a house on you, too!" --Glinda