Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!rpi!uupsi!sunic!nuug!ifi!pers From: pers@ifi.uio.no (Per Siljubergs}sen) Newsgroups: comp.sys.mac.programmer Subject: Access global variables from trap patches? Summary: No good solutions? Message-ID: <1990Sep24.231618.29949@ifi.uio.no> Date: 24 Sep 90 23:16:18 GMT Organization: Dept. of Informatics, University of Oslo, Norway Lines: 53 Nntp-Posting-Host: gille.ifi.uio.no Originator: pers@gille.ifi.uio.no I have a few questions I can't find any good answers too. I've looked everywhere, I hope. :-) I'm writing an extension to the system. It includes INIT code, VBL task and a couple of trap patches. I need global data so that the INIT and the patches can communicate. I would like to use A5 (the SAGlobals module from TN256) or a relocatable block in the system heap. Anyway, I need to store A5 or a handle to my globals between the calls somewhere. The usual tips regarding stand-alone code don't seem to help me. Say one of my patches need access to the globals: 1) The patch can't get it's hands on my A5 world or a handle to the globals through the parameters, because they (the parameters) must be the same as the trap. 2) I can't set up A5 before the patch gets called. I have no way to predict when the system or the applications will call the trap. Some solutions have come up. They are not very elegant, I think: 1) Save the A5 or the handle directly into my stand-alone code resource. Will this work with new processors like 68030 and 68040? These processors have intruction cache on the chip. Isn't this solution almost like selfmodifying code? 2) Use a driver for the communication. Overkill? 3) System 7.0 IPC? Is it possible? Even if it is, I would like this to work with System 6.x.x too. 4) A hack I read in Joel West's book "Programming with MPW", is to store the globals as an unpurgeable resource in the sys heap at INIT time. The type and ID of the resource is known, so my patch rutines can get access by a call to GetResource. Will this work at interrupt time? What is the best solution? Other solutions? Please, I need all the help I can get. I think many others would like some info on this too. -Per Per Siljubergsaasen, Dept. of Informatics, University of Oslo, Norway EMail: pers@ifi.uio.no