Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!van-bc!ubc-cs!alberta!dvinci!weyr!Jeff.Petkau From: Jeff.Petkau@weyr.FIDONET.ORG (Jeff Petkau) Newsgroups: comp.sys.amiga.tech Subject: resource tracking Message-ID: <355.25C92297@weyr.FIDONET.ORG> Date: 2 Feb 90 05:53:52 GMT Organization: Benden Weyr, Saskatoon Sk. (306)-382-5746 Lines: 44 Warning: If you do not enjoy watching the physical abuse of dead horses, stop reading this message. From article <130652@sun.Eng.Sun.COM>, by cmcmanis@stpeter.Sun.COM (Chuck McManis): > Think again. It isn't trivial, (let's here how you would do it in 1000 > words or less) and 90% of the time the cost in terms of extra code isn't > worth the hassle. You have to remember the entire Amiga kernel, some > supporting libraries and a couple of device drivers fits into 256K of > ROM. Compare and contrast how this would effect performance of simple > routines versus making sure routines that care are accurate. It _is_ trivial. For memory, simply keep a pointer in the task structure to the same sort of list that C compilers use for malloc(), or use intuition's Remember lists (automatically, that is.) For most other things (screens, windows, filehandles, locks, libraries, fonts...) keep a list of something like struct FunkyRemember { void (*CloseFunc)(); /* the function to close this object */ long Arg; /* the argument to pass closefunc */ struct FunkyRemember *Next; }; Now, say you call OpenScreen(). OpenScreen will create a new FunkyRemember with CloseFunc=CloseScreen, Arg=the screen pointer and link it into the list kept in your task structure. A special function could be provided to delink a resource from the list without closing it, in case you wanted to close it manually or keep it around after your program exited. The only basic requirement here is that all the CloseXXX() functions take a single parameter, and all in the same register. The only existing functions that might have trouble with are OpenDevice() and CloseDevice(), since they use the user's ioreq structure for closing. A patch would still be trivial, though; just provide a DirectCloseDevice() which takes the io_Device field instead of the ioreq containing it, and use that for the remember list. -- Jeff Petkau - via FidoNet node 1:140/22 UUCP: alberta!dvinci!weyr!Jeff.Petkau Internet: Jeff.Petkau@weyr.FIDONET.ORG Standard Disclaimers Apply...