Path: utzoo!utgpu!attcan!uunet!mcvax!enea!tut!santra!jmunkki From: jmunkki@santra.HUT.FI (Juri Munkki) Newsgroups: comp.sys.mac.programmer Subject: Re: sharing data between cdevs and INITs Summary: No problem, read on... Keywords: INIT cdev LSC DRVR Message-ID: <15674@santra.UUCP> Date: 25 Aug 88 18:01:41 GMT References: <1739@microsoft.UUCP> <15808@apple.Apple.COM> <1745@microsoft.UUCP> Sender: jmunkki@santra.UUCP Reply-To: jmunkki@santra.UUCP (Juri Munkki) Organization: Helsinki University of Technology, Finland Lines: 51 In <1745@microsoft.UUCP> t-benw@microsoft.uucp (Benjamin Waldman) writes: >The problem with this is that the INIT has to write to disk at startup >time, which I'd rather not do. Right... I did this by looking at memory manager structures the way that is suggested in the QuicKeys manual. >Actually, I've found a rather neat solution -- the device manager!! I think this is a better solution than the method I use. I haven't read TN#71, so there are some points I do not understand. How about some code fragments? >Unfortunately, there's one problem - Think C 3.0!!! >My driver has to be in the system heap, so it can stay alive all the time. >But while THINK C lets you set the resource flags for a code resource, it >doesn't let you do this for a driver. So every time, after building the >driver, I have to start ResEdit, and set the system heap bit. Ok. I had the same problem when building an INIT with LSC 2.15. That's why I wrote a small Fixer program to do the job. It also does some other things, but that's the reason I wrote it for. I posted it here a few months ago and it has been archived at least at macserve@pucc (BITNET). >But, wait, it gets worse. Think C lets you have global data in your >drivers by allocating a block in the heap for you, locking it, pointing >A4 to it, and referencing your globals off of A4. But my data has to >be in the system heap!!! So, in my open routine, I have to allocate >another block, in the system heap this time, copy my globals from where >Think C put them, and point A4 to my globals. (Actually, I store the >There's still one problem, however. Think C locks the handle that IT >allocated every time my driver is called. Suppose I call my driver >later on, after the application heap has been reinitialized (which is >OK, since my driver is in the system heap). The handle that THINK C >allocated is no longer valid. I wonder if THINK C's driver Since you open your driver from an INIT, you can simply set the current zone to the system heap. This will most probably make LSC allocate your variables from the system heap. I haven't tried this exactly, but I set the current zone in my INIT before I allocate some buffers & stuff and it works fine. I couldn't figure out how to make LSC allocate system heap blocks otherwise. When the driver returns, restore the correct heap zone. (You have to get it, change it, open your driver and restore the zone). I hope this works. Please try to write a document & post it. Juri Munkki jmunkki@santra.hut.fi jmunkki@fingate.bitnet