Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!elroy.jpl.nasa.gov!decwrl!claris!outpost.UUCP!peirce From: peirce@outpost.UUCP (Michael Peirce) Newsgroups: comp.sys.mac.programmer Subject: Re: INIT/cdev communication question Message-ID: <0B010004.moaxva@outpost.UUCP> Date: 24 Mar 91 23:55:42 GMT Reply-To: peirce@outpost.UUCP Organization: Peirce Software Lines: 42 X-Mailer: uAccess - Mac Release: 1.0.3 In article <91083.154101CXT105@psuvm.psu.edu>, CXT105@psuvm.psu.edu (Christopher Tate) writes: > > Is there anything wrong with this scheme: > > My INIT opens up a resource of a custom type and ID (chosen to minimize > possible conflicts) which contains the data which needs to be shared by > the INIT and the cdev. Since the INIT file is first in the resource > search chain, the INIT will always open the resource out of its own > file. > > The resource is MoveHHi'd into the top of the system heap and locked > down, but *not* DetachResource'd. The INIT gets various information > from this resource when needed. > > Now, the cdev calls GetResource() on that same resource type and ID. > Since the cdev is in the same file as the INIT, it gets a handle to > the resource image that's already stashed away in the system heap. > By altering the proper fields and calling WriteResource(), the cdev > can alter these persistent parameters both permanently and dynamically; > the INIT will encounter the new values in the memory image the next > time it looks. > > This scheme maintains the distinction between code and data; nothing > needs to be stored directly into the cdev or INIT resource images > themselves. Anyone see anything wrong with this approach? Well, when the INIT is done running, its resource fork will be closed. INITs don't run forever, they get a quick chance to run at startup time and if they expect to be around later must stash parts of themselves in the system somewhere. What's wrong with creating a block in the system heap and using Gestalt to register the pointer to it? Then the INIT's resident code (patch/TimeManager task/whatever) and the cdev can ask Gestalt for it. -- 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