xref: /freebsd/share/man/man3/pthread_condattr.3 (revision 9768746b)
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.\"
28.\" $FreeBSD$
29.Dd May 31, 2016
30.Dt PTHREAD_CONDATTR 3
31.Os
32.Sh NAME
33.Nm pthread_condattr_init ,
34.Nm pthread_condattr_destroy ,
35.Nm pthread_condattr_getclock ,
36.Nm pthread_condattr_setclock ,
37.Nm pthread_condattr_getpshared ,
38.Nm pthread_condattr_setpshared
39.Nd condition attribute operations
40.Sh LIBRARY
41.Lb libpthread
42.Sh SYNOPSIS
43.In pthread.h
44.Ft int
45.Fn pthread_condattr_init "pthread_condattr_t *attr"
46.Ft int
47.Fn pthread_condattr_destroy "pthread_condattr_t *attr"
48.Ft int
49.Fo pthread_condattr_getclock
50.Fa "pthread_condattr_t * restrict attr" "clockid_t * restrict clock_id"
51.Fc
52.Ft int
53.Fn pthread_condattr_setclock "pthread_condattr_t *attr" "clockid_t clock_id"
54.Ft int
55.Fo pthread_condattr_getpshared
56.Fa "pthread_condattr_t * restrict attr" "int * restrict pshared"
57.Fc
58.Ft int
59.Fn pthread_condattr_setpshared "pthread_condattr_t *attr" "int pshared"
60.Sh DESCRIPTION
61Condition attribute objects are used to specify parameters to
62.Fn pthread_cond_init .
63.Pp
64The
65.Fn pthread_condattr_init
66function initializes a condition attribute object with the default attributes.
67.Pp
68The
69.Fn pthread_condattr_destroy
70function destroys a condition attribute object.
71.Pp
72The
73.Fn pthread_condattr_getclock
74function will put the value of the clock attribute from
75.Fa attr
76into the memory area pointed to by
77.Fa clock_id .
78The
79.Fn pthread_condattr_setclock
80function will set the clock attribute of
81.Fa attr
82to the value specified in
83.Fa clock_id .
84The clock attribute affects the interpretation of
85.Fa abstime
86in
87.Xr pthread_cond_timedwait 3
88and may be set to
89.Dv CLOCK_REALTIME
90(default)
91or
92.Dv CLOCK_MONOTONIC .
93.Pp
94The
95.Fn pthread_condattr_getpshared
96function will put the value of the process-shared attribute from
97.Fa attr
98into the memory area pointed to by
99.Fa pshared .
100The
101.Fn pthread_condattr_setpshared
102function will set the process-shared attribute of
103.Fa attr
104to the value specified in
105.Fa pshared .
106The argument
107.Fa pshared
108may have one of the following values:
109.Bl -tag -width ".Dv PTHREAD_PROCESS_PRIVATE"
110.It Dv PTHREAD_PROCESS_PRIVATE
111The condition variable it is attached to may only be accessed by
112threads in the same process as the one that created the object.
113.It Dv PTHREAD_PROCESS_SHARED
114The condition variable it is attached to may be accessed by
115threads in processes other than the one that created the object.
116.El
117.Sh RETURN VALUES
118If successful, these functions return 0.
119Otherwise, an error number is returned to indicate the error.
120.Sh ERRORS
121The
122.Fn pthread_condattr_init
123function will fail if:
124.Bl -tag -width Er
125.It Bq Er ENOMEM
126Out of memory.
127.El
128.Pp
129The
130.Fn pthread_condattr_destroy
131function will fail if:
132.Bl -tag -width Er
133.It Bq Er EINVAL
134Invalid value for
135.Fa attr .
136.El
137.Pp
138The
139.Fn pthread_condattr_setclock
140function will fail if:
141.Bl -tag -width Er
142.It Bq Er EINVAL
143The value specified in
144.Fa clock_id
145is not one of the allowed values.
146.El
147.Pp
148The
149.Fn pthread_condattr_setpshared
150function will fail if:
151.Bl -tag -width Er
152.It Bq Er EINVAL
153The value specified in
154.Fa pshared
155is not one of the allowed values.
156.El
157.Sh SEE ALSO
158.Xr pthread_cond_init 3 ,
159.Xr pthread_cond_timedwait 3
160.Sh STANDARDS
161The
162.Fn pthread_condattr_init
163and
164.Fn pthread_condattr_destroy
165functions conform to
166.St -p1003.1-96
167