Re: pthread_cond_signal/broadcast: necessary to hold mutex?

Thomas Klausner <[email protected]> Tue, 24 Mar 2026 11:34:59 +0100
Newsgroups gmane.os.netbsd.current
Message-ID <[email protected]>
On Mon, Mar 23, 2026 at 05:19:18PM +0100, Greg Troxel wrote:
> Feels like bug report time to me.

This is now

lib/60122: pthread_cond_broadcast/signal man pages claim to need mutex held

I can do the man page changes, but would like confirmation first that
the code in libpthread really does not require the mutex held.

> Also, our man page talks about "changing the mutex" associated with the
> pthread_cond_t, but as I read POSIX there is no rule that you can't have
> N threads waiting on the same condvar each with a different mutex.  The
> mutex is just about the wait caller, holding it on entry and getting it
> back later, with it released in between.
> 
> It would be interesting to see what the code does; this could just be a
> doc issue.

How I understand the code is that a mutex is saved in the cond
structure, and there is only place for one - so I think the
requirement is actually true in NetBSD.
 Thomas