Download raw body.
mention mutex in pthread_cond_init.3?
On 2025-06-20, Mark Kettenis wrote: > > Date: Fri, 20 Jun 2025 13:25:15 +0000 > > From: Job Snijders <job@openbsd.org> > > > > Dear Guehnther / Tedu, > > > > As I understand it, a mutex must be used to protect the condition > > variable itself. So I think the below might help clarify the > > relationship between conditions and mutexes. OK? > > Yes, see pthread_cond_wait(3). But I don't think adding this here > helps in any way. There should be a link somewhere. Someone can probably figure it out, but man pthread_mutex_t doesn't work. I think it would be nice to have at least one link that actually goes to a mutex man page. Putting the text in pthread_cond_init is as good as anywhere, since you're likely going to init the mutex at the same time. > > > Index: ./man/pthread_cond_init.3 > > =================================================================== > > RCS file: /cvs/src/lib/libpthread/man/pthread_cond_init.3,v > > diff -u -p -r1.13 pthread_cond_init.3 > > --- ./man/pthread_cond_init.3 7 Jun 2025 00:16:52 -0000 1.13 > > +++ ./man/pthread_cond_init.3 20 Jun 2025 13:20:56 -0000 > > @@ -50,6 +50,8 @@ If > > is > > .Dv NULL , > > the default attributes are used. > > +.Pp > > +A condition variable must always be used in conjunction with a mutex. > > .Sh RETURN VALUES > > If successful, the > > .Fn pthread_cond_init > > @@ -76,7 +78,8 @@ variable. > > .Xr pthread_cond_destroy 3 , > > .Xr pthread_cond_signal 3 , > > .Xr pthread_cond_timedwait 3 , > > -.Xr pthread_cond_wait 3 > > +.Xr pthread_cond_wait 3 , > > +.Xr pthread_mutex_init 3 > > .Sh STANDARDS > > .Fn pthread_cond_init > > conforms to > > > > > >
mention mutex in pthread_cond_init.3?