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

  1. Path: univ-lyon1.fr!news
  2. From: Laurent GIROUD <milu28@bat710.univ-lyon1.fr>
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Re: Messages vs. Semaphores for external clocking
  5. Date: Fri, 05 Apr 1996 16:53:19 +0200
  6. Organization: C.I.S.M.  Universite de Lyon 1 / INSA de Lyon
  7. Message-ID: <316533DF.5BFD@bat710.univ-lyon1.fr>
  8. References: <4ju349$r1e@sparky.navsea.navy.mil>
  9.         <4jvrqs$hk0@btmpjg.god.bel.alcatel.be> <slN3BCS00iWZ0_8G1R@andrew.cmu.edu>
  10. NNTP-Posting-Host: miage.univ-lyon1.fr
  11. Mime-Version: 1.0
  12. Content-Type: text/plain; charset=us-ascii
  13. Content-Transfer-Encoding: 7bit
  14. X-Mailer: Mozilla 2.01 (X11; I; HP-UX A.09.04 9000/856)
  15.  
  16. > > Use global data, which your subtask fills with the timer-values,
  17. > > and the parent process reads. Disable() and Enable() multitasking
  18. > > when performing such a critical action (reading or writing from the
  19. > > global data). No message port or semaphore needed.
  20. > This is very, very bad advice. A message port or a semaphore is indeed
  21. > needed. Disable()/Enable() are bad programming styles, especially for
  22. > user level programs because they disable multitasking. Using semaphores
  23. > to protect critical sections is a much better solution. As a matter of
  24. > fact, this is exactly the type of situation semaphores are there for.
  25. > Berend Ozceri
  26.  
  27.    Of course but you must not forget something -> in order to be sure
  28. that
  29. the semaphore you are just refering to in your program is valid  you
  30. actually HAVE to FindName() it before and then to acces it in an atomic
  31. operation thus needing to embrace the two instructions (FindName + 
  32. ObtainSemaphore) in a Forbid()/Permit() pair...
  33.  
  34.    Exec's current implementation of the Semaphore is not quite ideal,
  35. It's the OS work to prevent the release of a semaphore when it is
  36. accessed
  37. by some user. The ObtainSemaphore() should ITSELF do a Forbid(), ensure
  38. that
  39. the semaphore is valid and then acces it (or Wait for it to be
  40. available), 
  41. returning the user with an error if the semaphore has been removed
  42. before.
  43.  
  44.   This could be added to "The OS improvement list" :) ...
  45.  
  46. Laurent Giroud
  47.