Hi ,
M Using the boost library for shared memory . where internally this locking
takes place.
But due to some reason thread holding the lock died .So when other thread
tries to lock the mutex. I t should throw EOWNERDEAD. But here it hangs.
(gdb) s
358 mp_mutex->lock();
(gdb) s
boost::interprocess::interprocess_recursive_mutex::lock (this=0xb76f8038)
at
/usr/local/include/boost/interprocess/sync/posix/interprocess_recursive_mutex.hpp:53
53 if (pthread_mutex_lock(&m_mut) != 0)
value of &m_mut is
= {__data = {__lock = 2, __count = 1, __owner = 16268, __kind = 1,
__nusers = 1, {__spins = 0, __list = {
__next = 0x0}}},
__size =
"\002\000\000\000\001\000\000\000\214?\000\000\001\000\000\000\001\000\000\000\000\000\000",
__align = 2}
note :the process id 16268 is not there in process list
1) How to take care of such situation.
2) if we can manually unlock the mutex of dead thread
3) is there any other way to check that dying thread , automatically
unlock .May be some explicit calls to be made.
4) or just time wait to be made . if lock doesnt get unlocked within that
period it should be unlocked automatically.
we are using:
Linux version 2.6.18-92.el5PAE (mockbuild@builder16.centos.org) (gcc
version 4.1.2 20071124 (Red Hat 4.1.2-42))
SMP Tue EDT 2008 i686 i686 i386 GNU/Linux
I am lil confused as pthread is one of the best library, bt its major lock
call is not retuening. What interrupt could have generated by o/s which
kills thread so abruptly.
Please help me out.
thanks
Suman
ps :
pthread_mutex_lock() return value
EOWNERDEAD
The last owner of this mutex died while holding the mutex. This mutex
is now owned by the caller. The caller must attempt to make the state
protected by the mutex consistent.
If the caller is able to make the state consistent, call
pthread_mutex_consistent_np() for the mutex and unlock the mutex.
Subsequent calls to pthread_mutex_lock() will behave normally.
If the caller is unable to make the state consistent, do not call
pthread_mutex_init() for the mutex, but unlock the mutex. Subsequent
calls to pthread_mutex_lock() fail to acquire the mutex and return an
ENOTRECOVERABLE error code.
If the owner that acquired the lock with EOWNERDEAD dies, the next
owner acquires the lock with EOWNERDEAD.