xref: /freebsd/share/man/man3/pthread_condattr.3 (revision cb2887746f8b9dd4ad6b1e757cdc053a08b25a2e)
1.\" Copyright (C) 2000 Jason Evans <jasone@FreeBSD.org>.
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice(s), this list of conditions and the following disclaimer as
9.\"    the first lines of this file unmodified other than the possible
10.\"    addition of one or more copyright notices.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice(s), this list of conditions and the following disclaimer in
13.\"    the documentation and/or other materials provided with the
14.\"    distribution.
15.\"
16.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
17.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
20.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23.\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25.\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26.\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27.Dd October 27, 2023
28.Dt PTHREAD_CONDATTR 3
29.Os
30.Sh NAME
31.Nm pthread_condattr_init ,
32.Nm pthread_condattr_destroy ,
33.Nm pthread_condattr_getclock ,
34.Nm pthread_condattr_setclock ,
35.Nm pthread_condattr_getpshared ,
36.Nm pthread_condattr_setpshared
37.Nd condition attribute operations
38.Sh LIBRARY
39.Lb libpthread
40.Sh SYNOPSIS
41.In pthread.h
42.Ft int
43.Fn pthread_condattr_init "pthread_condattr_t *attr"
44.Ft int
45.Fn pthread_condattr_destroy "pthread_condattr_t *attr"
46.Ft int
47.Fo pthread_condattr_getclock
48.Fa "pthread_condattr_t * restrict attr" "clockid_t * restrict clock_id"
49.Fc
50.Ft int
51.Fn pthread_condattr_setclock "pthread_condattr_t *attr" "clockid_t clock_id"
52.Ft int
53.Fo pthread_condattr_getpshared
54.Fa "pthread_condattr_t * restrict attr" "int * restrict pshared"
55.Fc
56.Ft int
57.Fn pthread_condattr_setpshared "pthread_condattr_t *attr" "int pshared"
58.Sh DESCRIPTION
59Condition attribute objects are used to specify parameters to
60.Fn pthread_cond_init .
61.Pp
62The
63.Fn pthread_condattr_init
64function initializes a condition attribute object with the default attributes.
65.Pp
66The
67.Fn pthread_condattr_destroy
68function destroys a condition attribute object.
69.Pp
70The
71.Fn pthread_condattr_getclock
72function will put the value of the clock attribute from
73.Fa attr
74into the memory area pointed to by
75.Fa clock_id .
76The
77.Fn pthread_condattr_setclock
78function will set the clock attribute of
79.Fa attr
80to the value specified in
81.Fa clock_id .
82The clock attribute affects the interpretation of
83.Fa abstime
84in
85.Xr pthread_cond_timedwait 3
86and may be set to
87.Dv CLOCK_REALTIME
88(default),
89.Dv CLOCK_TAI ,
90or
91.Dv CLOCK_MONOTONIC .
92.Pp
93The
94.Fn pthread_condattr_getpshared
95function will put the value of the process-shared attribute from
96.Fa attr
97into the memory area pointed to by
98.Fa pshared .
99The
100.Fn pthread_condattr_setpshared
101function will set the process-shared attribute of
102.Fa attr
103to the value specified in
104.Fa pshared .
105The argument
106.Fa pshared
107may have one of the following values:
108.Bl -tag -width ".Dv PTHREAD_PROCESS_PRIVATE"
109.It Dv PTHREAD_PROCESS_PRIVATE
110The condition variable it is attached to may only be accessed by
111threads in the same process as the one that created the object.
112.It Dv PTHREAD_PROCESS_SHARED
113The condition variable it is attached to may be accessed by
114threads in processes other than the one that created the object.
115.El
116See
117.Xr libthr 3
118for details of the implementation of shared condition variables,
119and their limitations.
120.Sh RETURN VALUES
121If successful, these functions return 0.
122Otherwise, an error number is returned to indicate the error.
123.Sh ERRORS
124The
125.Fn pthread_condattr_init
126function will fail if:
127.Bl -tag -width Er
128.It Bq Er ENOMEM
129Out of memory.
130.El
131.Pp
132The
133.Fn pthread_condattr_destroy
134function will fail if:
135.Bl -tag -width Er
136.It Bq Er EINVAL
137Invalid value for
138.Fa attr .
139.El
140.Pp
141The
142.Fn pthread_condattr_setclock
143function will fail if:
144.Bl -tag -width Er
145.It Bq Er EINVAL
146The value specified in
147.Fa clock_id
148is not one of the allowed values.
149.El
150.Pp
151The
152.Fn pthread_condattr_setpshared
153function will fail if:
154.Bl -tag -width Er
155.It Bq Er EINVAL
156The value specified in
157.Fa pshared
158is not one of the allowed values.
159.El
160.Sh SEE ALSO
161.Xr libthr 3 ,
162.Xr pthread_cond_init 3 ,
163.Xr pthread_cond_timedwait 3
164.Sh STANDARDS
165The
166.Fn pthread_condattr_init
167and
168.Fn pthread_condattr_destroy
169functions conform to
170.St -p1003.1-96
171