xref: /freebsd/share/man/man3/pthread_condattr.3 (revision c7c3ef8949021696029fb73a513678578a9f8a46)
1c5e7e03aSRuslan Ermilov.\" Copyright (C) 2000 Jason Evans <jasone@FreeBSD.org>.
24c089f4dSJason Evans.\" All rights reserved.
34c089f4dSJason Evans.\"
44c089f4dSJason Evans.\" Redistribution and use in source and binary forms, with or without
54c089f4dSJason Evans.\" modification, are permitted provided that the following conditions
64c089f4dSJason Evans.\" are met:
74c089f4dSJason Evans.\" 1. Redistributions of source code must retain the above copyright
84c089f4dSJason Evans.\"    notice(s), this list of conditions and the following disclaimer as
94c089f4dSJason Evans.\"    the first lines of this file unmodified other than the possible
104c089f4dSJason Evans.\"    addition of one or more copyright notices.
114c089f4dSJason Evans.\" 2. Redistributions in binary form must reproduce the above copyright
124c089f4dSJason Evans.\"    notice(s), this list of conditions and the following disclaimer in
134c089f4dSJason Evans.\"    the documentation and/or other materials provided with the
144c089f4dSJason Evans.\"    distribution.
154c089f4dSJason Evans.\"
164c089f4dSJason Evans.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
174c089f4dSJason Evans.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
184c089f4dSJason Evans.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
194c089f4dSJason Evans.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
204c089f4dSJason Evans.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
214c089f4dSJason Evans.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
224c089f4dSJason Evans.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
234c089f4dSJason Evans.\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
244c089f4dSJason Evans.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
254c089f4dSJason Evans.\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
264c089f4dSJason Evans.\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27*4f03a2caSKonstantin Belousov.Dd October 27, 2023
284c089f4dSJason Evans.Dt PTHREAD_CONDATTR 3
294c089f4dSJason Evans.Os
304c089f4dSJason Evans.Sh NAME
312a53c5ecSAlexey Zelkin.Nm pthread_condattr_init ,
32febae919SJilles Tjoelker.Nm pthread_condattr_destroy ,
33febae919SJilles Tjoelker.Nm pthread_condattr_getclock ,
34febae919SJilles Tjoelker.Nm pthread_condattr_setclock ,
35febae919SJilles Tjoelker.Nm pthread_condattr_getpshared ,
36a3fb6da9SGlen Barber.Nm pthread_condattr_setpshared
374c089f4dSJason Evans.Nd condition attribute operations
384c089f4dSJason Evans.Sh LIBRARY
39ec7452f1SRuslan Ermilov.Lb libpthread
404c089f4dSJason Evans.Sh SYNOPSIS
4132eef9aeSRuslan Ermilov.In pthread.h
424c089f4dSJason Evans.Ft int
434c089f4dSJason Evans.Fn pthread_condattr_init "pthread_condattr_t *attr"
444c089f4dSJason Evans.Ft int
454c089f4dSJason Evans.Fn pthread_condattr_destroy "pthread_condattr_t *attr"
46febae919SJilles Tjoelker.Ft int
479f3b6cdbSKonstantin Belousov.Fo pthread_condattr_getclock
489f3b6cdbSKonstantin Belousov.Fa "pthread_condattr_t * restrict attr" "clockid_t * restrict clock_id"
499f3b6cdbSKonstantin Belousov.Fc
50febae919SJilles Tjoelker.Ft int
5182012c27SEitan Adler.Fn pthread_condattr_setclock "pthread_condattr_t *attr" "clockid_t clock_id"
52febae919SJilles Tjoelker.Ft int
539f3b6cdbSKonstantin Belousov.Fo pthread_condattr_getpshared
549f3b6cdbSKonstantin Belousov.Fa "pthread_condattr_t * restrict attr" "int * restrict pshared"
559f3b6cdbSKonstantin Belousov.Fc
56febae919SJilles Tjoelker.Ft int
57febae919SJilles Tjoelker.Fn pthread_condattr_setpshared "pthread_condattr_t *attr" "int pshared"
584c089f4dSJason Evans.Sh DESCRIPTION
594c089f4dSJason EvansCondition attribute objects are used to specify parameters to
604c089f4dSJason Evans.Fn pthread_cond_init .
612a53c5ecSAlexey Zelkin.Pp
624c089f4dSJason EvansThe
634c089f4dSJason Evans.Fn pthread_condattr_init
644c089f4dSJason Evansfunction initializes a condition attribute object with the default attributes.
652a53c5ecSAlexey Zelkin.Pp
664c089f4dSJason EvansThe
674c089f4dSJason Evans.Fn pthread_condattr_destroy
684c089f4dSJason Evansfunction destroys a condition attribute object.
69febae919SJilles Tjoelker.Pp
70febae919SJilles TjoelkerThe
71febae919SJilles Tjoelker.Fn pthread_condattr_getclock
72febae919SJilles Tjoelkerfunction will put the value of the clock attribute from
73febae919SJilles Tjoelker.Fa attr
74febae919SJilles Tjoelkerinto the memory area pointed to by
75febae919SJilles Tjoelker.Fa clock_id .
76febae919SJilles TjoelkerThe
77febae919SJilles Tjoelker.Fn pthread_condattr_setclock
78febae919SJilles Tjoelkerfunction will set the clock attribute of
79febae919SJilles Tjoelker.Fa attr
80febae919SJilles Tjoelkerto the value specified in
81febae919SJilles Tjoelker.Fa clock_id .
82febae919SJilles TjoelkerThe clock attribute affects the interpretation of
83febae919SJilles Tjoelker.Fa abstime
84febae919SJilles Tjoelkerin
85febae919SJilles Tjoelker.Xr pthread_cond_timedwait 3
86febae919SJilles Tjoelkerand may be set to
87febae919SJilles Tjoelker.Dv CLOCK_REALTIME
88febae919SJilles Tjoelker(default)
89febae919SJilles Tjoelkeror
90febae919SJilles Tjoelker.Dv CLOCK_MONOTONIC .
91febae919SJilles Tjoelker.Pp
92febae919SJilles TjoelkerThe
93febae919SJilles Tjoelker.Fn pthread_condattr_getpshared
94febae919SJilles Tjoelkerfunction will put the value of the process-shared attribute from
95febae919SJilles Tjoelker.Fa attr
96febae919SJilles Tjoelkerinto the memory area pointed to by
97febae919SJilles Tjoelker.Fa pshared .
98febae919SJilles TjoelkerThe
99febae919SJilles Tjoelker.Fn pthread_condattr_setpshared
100febae919SJilles Tjoelkerfunction will set the process-shared attribute of
101febae919SJilles Tjoelker.Fa attr
102febae919SJilles Tjoelkerto the value specified in
103febae919SJilles Tjoelker.Fa pshared .
104febae919SJilles TjoelkerThe argument
105febae919SJilles Tjoelker.Fa pshared
106febae919SJilles Tjoelkermay have one of the following values:
107febae919SJilles Tjoelker.Bl -tag -width ".Dv PTHREAD_PROCESS_PRIVATE"
108febae919SJilles Tjoelker.It Dv PTHREAD_PROCESS_PRIVATE
109febae919SJilles TjoelkerThe condition variable it is attached to may only be accessed by
110febae919SJilles Tjoelkerthreads in the same process as the one that created the object.
111febae919SJilles Tjoelker.It Dv PTHREAD_PROCESS_SHARED
112febae919SJilles TjoelkerThe condition variable it is attached to may be accessed by
113febae919SJilles Tjoelkerthreads in processes other than the one that created the object.
114febae919SJilles Tjoelker.El
115*4f03a2caSKonstantin BelousovSee
116*4f03a2caSKonstantin Belousov.Xr libthr 3
117*4f03a2caSKonstantin Belousovfor details of the implementation of shared condition variables,
118*4f03a2caSKonstantin Belousovand their limitations.
1194c089f4dSJason Evans.Sh RETURN VALUES
1204c089f4dSJason EvansIf successful, these functions return 0.
1214c089f4dSJason EvansOtherwise, an error number is returned to indicate the error.
1224c089f4dSJason Evans.Sh ERRORS
1239d09157aSPhilippe CharnierThe
1244c089f4dSJason Evans.Fn pthread_condattr_init
1259d09157aSPhilippe Charnierfunction will fail if:
1264c089f4dSJason Evans.Bl -tag -width Er
1274c089f4dSJason Evans.It Bq Er ENOMEM
1284c089f4dSJason EvansOut of memory.
1294c089f4dSJason Evans.El
1302a53c5ecSAlexey Zelkin.Pp
1319d09157aSPhilippe CharnierThe
1324c089f4dSJason Evans.Fn pthread_condattr_destroy
1339d09157aSPhilippe Charnierfunction will fail if:
1344c089f4dSJason Evans.Bl -tag -width Er
1354c089f4dSJason Evans.It Bq Er EINVAL
1364c089f4dSJason EvansInvalid value for
1374c089f4dSJason Evans.Fa attr .
13842635956SRuslan Ermilov.El
139febae919SJilles Tjoelker.Pp
140febae919SJilles TjoelkerThe
141febae919SJilles Tjoelker.Fn pthread_condattr_setclock
142febae919SJilles Tjoelkerfunction will fail if:
143febae919SJilles Tjoelker.Bl -tag -width Er
144febae919SJilles Tjoelker.It Bq Er EINVAL
145febae919SJilles TjoelkerThe value specified in
146febae919SJilles Tjoelker.Fa clock_id
147febae919SJilles Tjoelkeris not one of the allowed values.
148febae919SJilles Tjoelker.El
149febae919SJilles Tjoelker.Pp
150febae919SJilles TjoelkerThe
151febae919SJilles Tjoelker.Fn pthread_condattr_setpshared
152febae919SJilles Tjoelkerfunction will fail if:
153febae919SJilles Tjoelker.Bl -tag -width Er
154febae919SJilles Tjoelker.It Bq Er EINVAL
155febae919SJilles TjoelkerThe value specified in
156febae919SJilles Tjoelker.Fa pshared
157febae919SJilles Tjoelkeris not one of the allowed values.
158febae919SJilles Tjoelker.El
1594c089f4dSJason Evans.Sh SEE ALSO
160*4f03a2caSKonstantin Belousov.Xr libthr 3 ,
161febae919SJilles Tjoelker.Xr pthread_cond_init 3 ,
162febae919SJilles Tjoelker.Xr pthread_cond_timedwait 3
1634c089f4dSJason Evans.Sh STANDARDS
1649d09157aSPhilippe CharnierThe
1654c089f4dSJason Evans.Fn pthread_condattr_init
1664c089f4dSJason Evansand
1674c089f4dSJason Evans.Fn pthread_condattr_destroy
1689d09157aSPhilippe Charnierfunctions conform to
169589a5e34SRuslan Ermilov.St -p1003.1-96
170