checking lock ownership
Craig Rodrigues
rodrigc at crodrigues.org
Fri Feb 13 07:07:16 PST 2004
On Fri, Feb 13, 2004 at 12:46:14PM +0100, Dag-Erling Sm?rgrav wrote:
> Is there any way, either in POSIX or in FreeBSD, to check if a given
> pthread_mutex_t is owned by the current thread?
One way is to try unlock it with pthread_mutex_unlock().
If that fails, and errno == EPERM, then the current thread
doesn't own the mutex.
For a less portable way, look at the source code
for _pthread_mutex_unlock() in
/usr/src/lib/libpthread/thread/thr_mutex.c
--
Craig Rodrigues
http://crodrigues.org
rodrigc at crodrigues.org
More information about the freebsd-threads
mailing list