[omniORB] Re: omnithreads/semaphore problem on WinNT 4.0

Duncan Grisby dgrisby@uk.research.att.com
Tue, 15 Aug 2000 17:42:30 +0100


On Tuesday 15 August, Georg Weissenbacher wrote:

> on WinNT 4.0 and hangs afterwards (join). It terminates, if I
> leave out the call to join, but it still doesn't print the
> "world" string :(
> 
> Is this a common problem or have I done something wrong?

The problem is that you are confusing condition variables with
semaphores. They are not the same thing. If you replace your use of
omni_condition with omni_semaphore, your code will behave as you
expect.

The semantics of wait() and signal() on a condition variable are
_only_ defined if they are called when the condition variable's
associated mutex is locked. Your code tries to use wait() and signal()
without having the mutex locked, which explains the differences
between platforms.

I recommend you read some documentation about condition variables. The
pthread manual pages are a good start (man pthread_cond_init).

Cheers,

Duncan.

-- 
 -- Duncan Grisby  \  Research Engineer  --
  -- AT&T Laboratories Cambridge          --
   -- http://www.uk.research.att.com/~dpg1 --