Thread Library Semaphores

Thread Library Semaphores

Post by L. Perry Sei » Sat, 08 Jul 2000 04:00:00



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

 
 
 

1. Thread Library Semaphores

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 hanging?

Thanks,
Perry Seip, MITRE Corporation

2. linux and ppp

3. C++ Library for Unix Threads, Mutexes, Semaphore etc

4. Weird ping response

5. Some C++ wrappers for threads, critical sections, semaphores and shared libraries.

6. Dumb Question?

7. Semaphore/thread mutex in multi threaded app.

8. SVGALib Where?

9. Runaway Linux processes-Native Posix Threading Library- Old linux threads

10. thread library--how to check on health of a thread?

11. threads, semaphore and condition question

12. x86 threads and semaphores

13. POSIX Thread Safe Semaphores & FreeBSD questions