Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!decwrl!adobe!hawley From: hawley@adobe.COM (Steve Hawley) Newsgroups: comp.sys.mac.programmer Subject: Re: Background MAGIC (and I don't mean multifinder!!) Message-ID: <5405@adobe.UUCP> Date: 10 Aug 90 18:49:43 GMT References: <1990Aug9.203803.13885@ecn.purdue.edu> Reply-To: hawley@adobe.UUCP (Steve Hawley) Organization: Adobe Systems Incorporated, Mountain View Lines: 41 In article <1990Aug9.203803.13885@ecn.purdue.edu> moyman@ecn.purdue.edu (James M Moya) writes: >How is it that cdev/INIT's like Moire and SuperClock (and many others) can >run in the background whether multifinder is running or not!! I have been >checking every mac bnook I know of to learn of this black magic...NOTHING. > >Exactly what is it they are doing?? Or does anybody *really* know... I can't answer your question as to what they are doing, but I can tell you a few ways that this can be done (although not in specifics). First: you need to have your code running in the system heap so that it hangs around no matter what application is running. Second: You need some mechanism to have your function called periodically. Here are a few ways to do this: 1) have your job submitted as a VBL task. You can have it scheduled to run with a granularity down to 1/60th of a second. 2) Write a driver (file type DRVR, I think), which can also be accessed every so many clock ticks. Both of these get called at the interrupt level, so you cannot execute any of the 3 million toolbox functions that move memory. This includes pretty much everything useful (like drawing to the screen, but I'm sure someone like Tim Maroney will correct me on this, since he has all the memory moving traps memorized :'). 3) Patch a common trap that gets called a lot (like GetNextEvent() or WaitNextEvent()). This will not give you any control over granularity (in fact, you may NEVER get called), so you lose there. Also, you will most certainly conflict with every other Mac program in the world which patches traps (since I understand, that is an in-vogue thing to do) and you will have a hairy time trying to support it (hint: if you make it big, you just blame compatability problems on everyone else's software, another in-vogue practice), but you can get at QuickDraw. Conclusion: Doable. It ain't easy. It's probably not fun, at least not my idea of fun. Steve Hawley hawley@adobe.com -- "Break out the cameras that reshape my face and get someone to carve up my head" -Alcatraz, "God Blessed Video"