1PTHREAD_RWLOCK_DESTROY(3P) POSIX Programmer's ManualPTHREAD_RWLOCK_DESTROY(3P)
2
3
4
6 This manual page is part of the POSIX Programmer's Manual. The Linux
7 implementation of this interface may differ (consult the corresponding
8 Linux manual page for details of Linux behavior), or the interface may
9 not be implemented on Linux.
10
11
13 pthread_rwlock_destroy, pthread_rwlock_init — destroy and initialize a
14 read-write lock object
15
17 #include <pthread.h>
18
19 int pthread_rwlock_destroy(pthread_rwlock_t *rwlock);
20 int pthread_rwlock_init(pthread_rwlock_t *restrict rwlock,
21 const pthread_rwlockattr_t *restrict attr);
22 pthread_rwlock_t rwlock = PTHREAD_RWLOCK_INITIALIZER;
23
25 The pthread_rwlock_destroy() function shall destroy the read-write lock
26 object referenced by rwlock and release any resources used by the lock.
27 The effect of subsequent use of the lock is undefined until the lock is
28 reinitialized by another call to pthread_rwlock_init(). An implementa‐
29 tion may cause pthread_rwlock_destroy() to set the object referenced by
30 rwlock to an invalid value. Results are undefined if
31 pthread_rwlock_destroy() is called when any thread holds rwlock.
32 Attempting to destroy an uninitialized read-write lock results in unde‐
33 fined behavior.
34
35 The pthread_rwlock_init() function shall allocate any resources
36 required to use the read-write lock referenced by rwlock and initial‐
37 izes the lock to an unlocked state with attributes referenced by attr.
38 If attr is NULL, the default read-write lock attributes shall be used;
39 the effect is the same as passing the address of a default read-write
40 lock attributes object. Once initialized, the lock can be used any num‐
41 ber of times without being reinitialized. Results are undefined if
42 pthread_rwlock_init() is called specifying an already initialized read-
43 write lock. Results are undefined if a read-write lock is used without
44 first being initialized.
45
46 If the pthread_rwlock_init() function fails, rwlock shall not be ini‐
47 tialized and the contents of rwlock are undefined.
48
49 Only the object referenced by rwlock may be used for performing syn‐
50 chronization. The result of referring to copies of that object in calls
51 to pthread_rwlock_destroy(), pthread_rwlock_rdlock(),
52 pthread_rwlock_timedrdlock(), pthread_rwlock_timedwrlock(),
53 pthread_rwlock_tryrdlock(), pthread_rwlock_trywrlock(),
54 pthread_rwlock_unlock(), or pthread_rwlock_wrlock() is undefined.
55
56 In cases where default read-write lock attributes are appropriate, the
57 macro PTHREAD_RWLOCK_INITIALIZER can be used to initialize read-write
58 locks. The effect shall be equivalent to dynamic initialization by a
59 call to pthread_rwlock_init() with the attr parameter specified as
60 NULL, except that no error checks are performed.
61
62 The behavior is undefined if the value specified by the attr argument
63 to pthread_rwlock_init() does not refer to an initialized read-write
64 lock attributes object.
65
67 If successful, the pthread_rwlock_destroy() and pthread_rwlock_init()
68 functions shall return zero; otherwise, an error number shall be
69 returned to indicate the error.
70
72 The pthread_rwlock_init() function shall fail if:
73
74 EAGAIN The system lacked the necessary resources (other than memory) to
75 initialize another read-write lock.
76
77 ENOMEM Insufficient memory exists to initialize the read-write lock.
78
79 EPERM The caller does not have the privilege to perform the operation.
80
81 These functions shall not return an error code of [EINTR].
82
83 The following sections are informative.
84
86 None.
87
89 Applications using these and related read-write lock functions may be
90 subject to priority inversion, as discussed in the Base Definitions
91 volume of POSIX.1‐2008, Section 3.287, Priority Inversion.
92
94 If an implementation detects that the value specified by the rwlock
95 argument to pthread_rwlock_destroy() does not refer to an initialized
96 read-write lock object, it is recommended that the function should fail
97 and report an [EINVAL] error.
98
99 If an implementation detects that the value specified by the attr argu‐
100 ment to pthread_rwlockr_init() does not refer to an initialized read-
101 write lock attributes object, it is recommended that the function
102 should fail and report an [EINVAL] error.
103
104 If an implementation detects that the value specified by the rwlock
105 argument to pthread_rwlock_destroy() or pthread_rwlock_init() refers to
106 a locked read-write lock object, or detects that the value specified by
107 the rwlock argument to pthread_rwlock_init() refers to an already ini‐
108 tialized read-write lock object, it is recommended that the function
109 should fail and report an [EBUSY] error.
110
112 None.
113
115 pthread_rwlock_rdlock(), pthread_rwlock_timedrdlock(),
116 pthread_rwlock_timedwrlock(), pthread_rwlock_trywrlock(),
117 pthread_rwlock_unlock()
118
119 The Base Definitions volume of POSIX.1‐2008, Section 3.287, Priority
120 Inversion, <pthread.h>
121
123 Portions of this text are reprinted and reproduced in electronic form
124 from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
125 -- Portable Operating System Interface (POSIX), The Open Group Base
126 Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
127 cal and Electronics Engineers, Inc and The Open Group. (This is
128 POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the
129 event of any discrepancy between this version and the original IEEE and
130 The Open Group Standard, the original IEEE and The Open Group Standard
131 is the referee document. The original Standard can be obtained online
132 at http://www.unix.org/online.html .
133
134 Any typographical or formatting errors that appear in this page are
135 most likely to have been introduced during the conversion of the source
136 files to man page format. To report such errors, see https://www.ker‐
137 nel.org/doc/man-pages/reporting_bugs.html .
138
139
140
141IEEE/The Open Group 2013 PTHREAD_RWLOCK_DESTROY(3P)