[omniORB] Condition varaibles - follow up...
Gary D. Duzan
gdd0@gte.com
Thu, 21 Jan 1999 09:30:27 -0500
On a similar note, I believe the OmniEvents service as released has
the same condition usage problem, which allows it to work on Linux but
causes problems on other platforms. I have notified the code's owner
and provided a patch for the locking as well as some AIX-specific
fixes, which will hopefully be included in an upcoming release.
Gary Duzan
GTE Laboratories
In Message <36A7307F.721BC1E3@ifad.dk> ,
Ole Storm <storm@ifad.dk> wrote:
=>Hi,
=>
=>Sai-Lai Lo wrote:
=>>
=>> Hi Ole,
=>>
=>> I think there is some misunderstanding on how to use conditional variable.
=>> In your code, you have never lock the mutex cond_mutex which is the mutex
=>> that you have initialised the conditional variables empty_buf and full_buf.
=>>
=>> Remember in your code, the conditional variables have to be initialised
=>> with a mutex as the ctor argument. When you use wait(), it is a
=>> pre-condition that the calling thread must hold the lock on the mutex with
=>> which the conditional variable is held. This is how the semantics of wait()
=>> is defined. (The wait operation may atomically **unlocks** the mutex and
=>> blocks the thread.)
=>
=>Yes, you are right, I misunderstood the use of condition varaibles. My
=>condition variables were initialized with a mutex all-right, but another
=>mutex that the one used by the function doing the wait(). I was not aware
=>that the condition varaible should actually be initialized with the mutex
=>that is used in the synchronization.
=>
=>My problem is now solved! Thanks to everyone who responded, and my
=>apollogies to Shinji - you vere right all the way!!!
=>
=>
=>Best regards,
=>
=> Ole.
=>