Click to See Complete Forum and Search --> : Id of thread with mutex lock


sszd
May 19th, 2006, 09:31 PM
This question is strictly for POSIX threads only. Is there a way to determine which thread may have a lock on a particular mutex? What I would like is to be able to programmatically obtain the thread id of the thread that currently has a lock on a given mutex. I can obviously determine whether or not a lock exists by either using the pthread_mutex_trylock() call, or by initializing the mutex in question with a PTHREAD_MUTEX_ERRORCHECK attribute and then checking the status of a pthread_mutex_lock() or pthread_mutex_unlock () call. What I’ve been unable to do is find any type of POSIX function call that will give me the thread identifier of which thread currently has the lock. Any help would be appreciated. Thank you.