home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 2632 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.1 KB

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