Path: utzoo!attcan!uunet!samsung!usc!apple!dlyons From: dlyons@Apple.COM (David A. Lyons) Newsgroups: comp.sys.apple2 Subject: Re: Argh! That blasted StartUpTools()! Message-ID: <42768@apple.Apple.COM> Date: 7 Jul 90 22:51:43 GMT References: <9007071530.AA09375@apple.com> Organization: Apple Computer Inc, Cupertino, CA Lines: 60 In article <9007071530.AA09375@apple.com> JWANKERL%UTCVM@PUCC.PRINCETON.EDU ("Josef W. Wankerl") writes: >Okay, so now I'll call MMStartUp to get an ID for my NDA, and then >MMShutDown when I no longer need my ID, right? MMStartUp doesn't _allocate_ an ID for you--it only tells you the ID that you already have (that is, it returns the ID owning the memory block that you're calling from). Your NDA already "has" an ID, which the system previously allocated using GetNewID. Don't call MMShutDown, because you're *not* through with your ID...your DA's code is still in memory with that ID (see description of MMShutDown in TB Ref 1). If you want to do a DisposeAll, don't do it with the ID MMStartUp returns-- instead, you can fiddle with the auxID field ($0x00), allocate blocks with that modified ID, and DisposeAll only on a modified ID (see GS Technical Note #17, "Application Memory Management and the MMStartUp ID"--some of the wisdom in there applies to non-applications). >[...] >Add another set of calls to the Desk Manager named NowNeedsTool() and >NoLongerNeedsTool(). NowNeedsTool will take a list of tools that a NDA >requires to operate and start them up if they aren't already. It will >then return an ID to the program that NoLongerNeedsTool will take. >By calling one central routine to start and stop tools, this will ensure >that the tools are always there for the DA that needs them. >NoLongerNeedsTool will take the ID returned by NowNeedsTool and check >to see if another ID needs that tool. If so, it is left alone. If not, >the tool is shut down. Simple and elegant, I think. I'm noture about -simple-, but it sounds like a reasonable start. It wouldn't even have to be new functions--StartUpTools and ShutDownTools (which are currently *not* recommended for NDA use under 5.0.x!) have plenty of extra bits in the startStopRefDesc if needed. Maybe StartUpTools/ShutDownTools could keep a list of all the "active" startStopToolsRecs (I don't think they currently do) and be intelligent about when to actually shut things down. This still leaves big questions about LoadOneTool, UnloadOneTool, LoadTools, StartUpTools, ShutDownTools, and *all* xxxStartUp and xxxShutDown functions, which applications and DAs are allowed to call directly (after all, they were around before SUT/SDT were). For example, there would have to be a mechanism preventing an application from shutting down a tool that it originally started but that is not being used by a DA. I think the system would have to intercept all startup and shutdown functions and be selective about letting them execute. UnloadOneTool would have to be handled similarly. Food for thought. -- David A. Lyons, Apple Computer, Inc. | DAL Systems Apple II Developer Technical Support | P.O. Box 875 America Online: Dave Lyons | Cupertino, CA 95015-0875 GEnie: D.LYONS2 or DAVE.LYONS CompuServe: 72177,3233 Internet/BITNET: dlyons@apple.com UUCP: ...!ames!apple!dlyons My opinions are my own, not Apple's.