[omniORB] Condition varaibles - follow up...

Ole Storm storm@ifad.dk
Thu, 21 Jan 1999 14:49:51 +0100


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.