Path: utzoo!news-server.csri.toronto.edu!rutgers!att!linac!pacific.mps.ohio-state.edu!zaphod.mps.ohio-state.edu!wuarchive!uunet!tnc!m0154 From: m0154@tnc.UUCP (GUY GARNETT) Newsgroups: comp.sys.amiga.programmer Subject: Re: Starting another copy of your own code (was Re: Help! (AmigaDOS CreateProc/LoadSeg) Message-ID: <752@tnc.UUCP> Date: 12 Mar 91 21:28:44 GMT References: <63329@eerie.acsu.Buffalo.EDU> <19578@cbmvax.commodore.com> <06417.AA06417@babylon.rmt.sub.org> <18cb4d63.ARN0b56@swinjm.UUCP> <1991Mar9.170859.4810@Sandelman.OCUnix.On.Ca> <06493.AA06493@babylon.rmt.sub.org> Reply-To: m0154@tnc.UUCP (GUY GARNETT) Organization: The Next Challenge, Fairfax, Va. Lines: 25 I don't think that the examples described previously are self-modifying code (at least, not from the point of view of a 680x0 family processor). The reason: Self modifying code (the kind which causes programs to break) is where some values got into the code cache, and then were changed (by whatever agency method; its not important). When the program goes back to re-execute the instruction (its probably inside some kind of loop), if the cache hits (probably) then we execute the old (before change) instruction (on a miss, everything works fine). In the example code from AmigaMail, the 'code' is a single instruction which is built into a data structure. When it is branched to, the code cache will miss (that location has never been executed before; yes, the value is in the DATA chache, but the two are separate entities). Therefore, the method should be safe, as long as each separate task to be launched has its own CodeHdr. If you try to re-use a CodeHdr (by stuffing a new value in CodeHdr.Function) then it *IS* self-modifying code, and may fail. The method is also always safe if you invalidate the cache right after you put a value in CodeHdr.Function; this will work no matter how many times you try to re-use the structure (of course, trying to re-use CodeHdr will probably have other side-effects as well). Wildstar