cvs commit: src/include pthread_np.h src/lib/libthr src/lib/libthr/thread thr_mutex.c

Daniel Eischen deischen at
Mon Feb 4 07:48:06 PST 2008

On Mon, 4 Feb 2008, Dag-Erling Smørgrav wrote:

> Dag-Erling Smorgrav <des at> writes:
>>   Log:
>>   Add pthread_mutex_islocked_np(), a cheap way to verify that a mutex is
>>   locked.  This is intended primarily to support the userland equivalent
>>   of the various *_ASSERT_LOCKED() macros we have in the kernel.
> I'm having second thoughts about this one.  There is a significant risk
> of false positives if the mutex is currently locked by another thread.
> I'm wondering whether to a) change the implementation so it only returns
> true if the mutex is owned by the current thread, or b) change the
> interface so you can specify a specific thread, or NULL for "any".

I thought you wanted to know if it was locked regardless of who
locked it.  If you want to know if the current thread has it
locked, it should be called pthread_mutex_isowned_np().

I don't really see the utility in any other behavior, and almost
question the need for _isowned.  I wonder if all the _np() functions
should be in the FBSDprivate namespace...


More information about the cvs-src mailing list