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