home *** CD-ROM | disk | FTP | other *** search
- Path: hub-n.franken.de!sokrates!snfuchs
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: Removing a patch - solved?
- From: snfuchs@sokrates.franken.de (Stefan Fuchs)
- Message-ID: <snfuchs.0cvn@sokrates.franken.de>
- Date: Fri, 2 Feb 96 19:27:46 GMT
- Organization: USS Enterprise BBS, Fuerth, Germany, +49-(0)911-7568701
-
- Nils Peter Sudmann wrote:
-
- > On 01-Feb-96 12:01:01, Jimmy Westerlund (ing9435@ind.mh.se) wrote:
- > >In article <1433.6603T1100T1439@stud.cs.uit.no>, Nils Peter Sudmann wrote:
- >
- > >> The problem is that some program
- > >>could be executing inside your patched code (and currently waiting for a
- > >>time slice). AFAIK there is *no* way to safely know when the last thread
- > of >>control has left your code (and you may unload it). So a patch should
- > >>actually never remove itself (only render itself inactive). I did miss the
- > >>previous patch discussion, but I wrote one myself and came to the above
- > >>conclusion. Right or wrong?
- >
- > > Wouldn't this work:
- >
- > > patch:
- > >addq.l#1,counter
- >
- > >; Patch stuff
- >
- > >exit_patch:
- > >subq.l#1,counter
- > >rts
- >
- > Nope, if a task-switch occurs just after the jump to 'patch:' *but* before
- > the addq, you're sold. Same goes for the subq -> rts. I'ill agree that the
- > odds of
- > this happening are pretty small. But it is not *correct*.
- >
- Just had an idea to solve this (not very nice, I agree), but it should work:
-
- When removing the patch first check the usecounter.
- If it is zero get the current pc for every task from the exec/tasklist.
- Compare the pc with the address of the addq.l #1,usecounter instruction and
- with the address of the rts instruction. If any match is found assume that
- the usecounter is not zero and act accordingly.
- If no match can be found I would say it is 100% save to remove the patch.
-
- The pc of each task is stored on the user-stack, the pointer to the current
- stack position is stored in the task structure.
-
- Might implement this in an upcomming version of patch.library.
-
- Like to hear your opinion.
-
-
- Stefan Fuchs snfuchs@sokrates.franken.de
-
- --
-
- ___ Offline Orbit v0.80 (Unregistered Evaluation Copy)
-