I have two threads within a single process running on Solaris 7 that
communicate via a custom message queue library. This library is
basically just a set of buffers controlled by a semaphore created
using the libthread tools. I have a basic 'ping' message which occurs
once per second and is passed through the message queue from one
thread to the other. One thread is pending on sleep(1) and the other is
pending on a message queue receive. The latter is simply waiting for
the semaphore to be posted by the sending routine.
The problem is that the thread pending on the semaphore locks after a
random period between 1 and 90 hours. Messages are posted by the
sending thread each second, but cease to be taken. One clue is that
when a carriage return is hit on the keyboard, the semaphore is taken.
There is a third thread that pends on keyboard input. However, when
this thread is eliminated from the code, the problem between the two
original threads continues.
The simple question is: Why is the semaphore take*?
Thanks,
Perry Seip, MITRE Corporation