Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!hao!ames!ucbcad!ucbvax!hoser.berkeley.edu!bryce From: bryce@hoser.berkeley.edu (Bryce Nesbitt) Newsgroups: comp.sys.amiga Subject: Re: Use of Resident Message-ID: <21428@ucbvax.BERKELEY.EDU> Date: Sat, 24-Oct-87 18:06:09 EST Article-I.D.: ucbvax.21428 Posted: Sat Oct 24 18:06:09 1987 Date-Received: Mon, 26-Oct-87 04:48:13 EST References: <4086@garfield.UUCP> Sender: usenet@ucbvax.BERKELEY.EDU Reply-To: bryce@hoser.berkeley.edu.UUCP (Bryce Nesbitt) Organization: Center Tapped Solids, Inc. Lines: 94 In article <4086@garfield.UUCP> john13@garfield.UUCP (John Russell) writes: >-- >I recently read that non-reentrant programs can still be made resident as >long as you only attempt to run one copy at a time.... This is nice if you have enough memory to keep ONE copy of the program (say, a compiler) in RAM, but not enough to keep the program in RAM *and* in the RAM disk. >I know this isn't the favourite topic for the CBM people on the net, but is >this fact at least accurate? Not a CBM person, but... yes it is... read on. >It would seem to be handy for advanced users >who would take adequate care. (On the wish list, if not a resident that >works well for everything, how about a DOS loader that looks at a resident >program's reference count and refuses to let you run it if it's non-zero >and the program is non-reentrant?). There are two clases of resident compatibility: REUSABLE This means you can run a program, exit, then run the same memory image again. The only restriction is no self modifying code that does not unmodify itself, and don't destroy any static initialized data that is need next run. Most C programs qualify. For the purposes of this resident, RESUABLE also implied CLEAN. This means that at any time a copy of the program could be made... no self modifying of any initized code or data permitted. This was expected to change to accomodate static initilization better... probably by keeping a separate copy of any volitile hunks. REENTRANT This means you can run the same program twice in the same memory image. We'll assume a single progcessor environment :-). MMU's can be convinced this type of thing is proper, so no troubles here. With this more stringent requirement you can't do *any* self modifying code, you must specifically AllocMem *ANY* memory that you write to. THIS MEANS NO GLOBALS FROM C! Worse yet, the standard startup modules violate this rule for stdin, stdout, sysbase etc. Since local varriables are allocated on the stack at run time, that is ok. Few Amiga programs qualify as of yet. All the BCPL programs in the c: directory do. For comparison, all of the Amiga ROM routines must be reentrant, since any task can call them. Under V1.1 DisplayBeep() was not reentrant, causing problems (source: V1.2 change notes). REENTRANT implies RESUSABLE and CLEAN. A while back I wrote most of a Resident that used a great deal of heuristics to determine what class an executable was in. For example it could detect BCPL and notice BSS hunks. It could also notice a special HUNK that had a format something like this: hunk_startupinfo LONG numlongs ;how long is this hunk? LONG minstacksize ;absolute minimum stack needed LONG flags This project lost steam when I got enough memory not to care. Now everything lives in VD0: and will come back "from the dead". A recoverable resident is a hot idea... The flags are I_AM_REENTRANT I_AM_REUSABLE I_AM_CLEAN and SEPARATE_INVOCATION. (more flags could be added) The first three are obvious, the third can be set to force separete invocation even if the program is reentrant and/or reusable. If the program is NOT reusable the new resident was to treat itself as a RAM disk, it would "reload" the program for each invocation. If the program was clean and reusable, but NOT reentrant, the new resident was to look at the use count. If it was in use, it would "reload" another copy. Else it would simply start it running in place. Not clean, but not resuable was only at the planning stage. It would either require another entire copy of the program, or a way to flag the dirty hunks. If the program WAS reentrant, the new resident would increment the use counter and start the program in place. None of this was very complex. As a long term solution it is probably better to have a "real" DOS. (or some real CAOS :-) |\ /| . Ack! (NAK, SOH, EOT) {o O} . bryce@hoser.berkeley.EDU -or- ucbvax!hoser!bryce (") U "Here. This'll shoot the lips off a cockroch" -Freedom Fighter