home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / sys / amiga / programm / 15476 < prev    next >
Encoding:
Internet Message Format  |  1992-11-08  |  2.0 KB

  1. Path: sparky!uunet!oracle!unrepliable!bounce
  2. Newsgroups: comp.sys.amiga.programmer
  3. From: dnavas@oracle.uucp (David Navas)
  4. Subject: Re: How to program multi-threaded programs on Amiga ?
  5. Message-ID: <1992Nov6.165355.23882@oracle.us.oracle.com>
  6. Sender: usenet@oracle.us.oracle.com (Oracle News Poster)
  7. Nntp-Posting-Host: mailseq.us.oracle.com
  8. Organization: Oracle Corporation, Redwood Shores CA
  9. References: <36604@cbmvax.commodore.com> <RNlXr*DG7@garfield.fipnet.fi>
  10. Date: Fri, 6 Nov 1992 16:53:55 GMT
  11. X-Disclaimer: This message was written by an unauthenticated user
  12.               at Oracle Corporation.  The opinions expressed are those
  13.               of the user and not necessarily those of Oracle.
  14. Lines: 25
  15.  
  16. In article <RNlXr*DG7@garfield.fipnet.fi> vsaari@garfield.fipnet.fi (Ville Saari) writes:
  17. >What is the right way for sub-process to exit and how can the main process
  18. >be absolutely sure the sub-process has exited?
  19.  
  20. To exit, return from the function that CreateNewProc() called....
  21. I ObtainSharedSemaphore() on entry to the subprocess.  And Release() it on
  22. exit.
  23. I attempt to ObtainSemaphore() on exit of the main process....
  24.  
  25. There is, unfortunately, a hole between the ReleaseSemaphore() and the return
  26. from the entrypoint.  Anyone know how to eliminate this (without a Forbid())?
  27. Also, be careful, there are race conditions on startup (if your main
  28. process attempts to leave before your startup process has ObtainShared()) --
  29. these are possible to fix pretty easily, though....
  30.  
  31. Actually, the hole I'm talking about is even worse -- my ReleaseSemaphore()
  32. occurs in library code, not user-program code, so what -can- happen is
  33. that the main program attempts to exit, the library code gets an EXPUNGE, and
  34. the sub-process is left executing out of someone else's memory ;)
  35.  
  36. I think the only way to eliminate this problem is to Forbid() -without-
  37. a matching Permit(), right before your ReleaseSemaphore() (of your
  38. subprocess).
  39. David C. Navas                        dnavas@oracle.com
  40. Working for, but not speaking on behalf of, Oracle Corp.
  41.