Porting a multi-threaded application from AIX to HP-UX 11.11. Have some
global structures in shared memory that several threads need update
protected access to. Using sem_wait and sem_post to provide
'locked/unlocked ' access to the global structures.

Every few minutes one of the threads is able to lock a pthread_mutex_t
variable that another thread has already locked (verified by a
chronological message trace). Is there a C compiler option or library
that will provide thread safe behavior when the pthread_mutex_t
variable is in a structure in shared memory when access is being
controlled by sem_wait and sem_post?

Thanks in advance.