1PTHREAD_RWLOCK_DESTROY(3P) POSIX Programmer's ManualPTHREAD_RWLOCK_DESTROY(3P)
2
3
4

PROLOG

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

NAME

12       pthread_rwlock_destroy, pthread_rwlock_init — destroy and initialize  a
13       read-write lock object
14

SYNOPSIS

16       #include <pthread.h>
17
18       int pthread_rwlock_destroy(pthread_rwlock_t *rwlock);
19       int pthread_rwlock_init(pthread_rwlock_t *restrict rwlock,
20           const pthread_rwlockattr_t *restrict attr);
21       pthread_rwlock_t rwlock = PTHREAD_RWLOCK_INITIALIZER;
22

DESCRIPTION

24       The pthread_rwlock_destroy() function shall destroy the read-write lock
25       object referenced by rwlock and release any resources used by the lock.
26       The effect of subsequent use of the lock is undefined until the lock is
27       reinitialized by another call to pthread_rwlock_init().  An implementa‐
28       tion may cause pthread_rwlock_destroy() to set the object referenced by
29       rwlock   to   an   invalid   value.   Results    are    undefined    if
30       pthread_rwlock_destroy()  is  called  when  any  thread  holds  rwlock.
31       Attempting to destroy an uninitialized read-write lock results in unde‐
32       fined behavior.
33
34       The   pthread_rwlock_init()   function  shall  allocate  any  resources
35       required to use the read-write lock referenced by rwlock  and  initial‐
36       izes  the lock to an unlocked state with attributes referenced by attr.
37       If attr is NULL, the default read-write lock attributes shall be  used;
38       the  effect  is the same as passing the address of a default read-write
39       lock attributes object. Once initialized, the lock can be used any num‐
40       ber  of  times  without  being  reinitialized. Results are undefined if
41       pthread_rwlock_init() is called specifying an already initialized read-
42       write  lock. Results are undefined if a read-write lock is used without
43       first being initialized.
44
45       If the pthread_rwlock_init() function fails, rwlock shall not  be  ini‐
46       tialized and the contents of rwlock are undefined.
47
48       See  Section  2.9.9, Synchronization Object Copies and Alternative Map‐
49       pings for further requirements.
50
51       In cases where default read-write lock attributes are appropriate,  the
52       macro  PTHREAD_RWLOCK_INITIALIZER  can be used to initialize read-write
53       locks. The effect shall be equivalent to dynamic  initialization  by  a
54       call  to  pthread_rwlock_init()  with  the  attr parameter specified as
55       NULL, except that no error checks are performed.
56
57       The behavior is undefined if the value specified by the  attr  argument
58       to  pthread_rwlock_init()  does  not refer to an initialized read-write
59       lock attributes object.
60

RETURN VALUE

62       If successful, the pthread_rwlock_destroy()  and  pthread_rwlock_init()
63       functions  shall  return  zero;  otherwise,  an  error  number shall be
64       returned to indicate the error.
65

ERRORS

67       The pthread_rwlock_init() function shall fail if:
68
69       EAGAIN The system lacked the necessary resources (other than memory) to
70              initialize another read-write lock.
71
72       ENOMEM Insufficient memory exists to initialize the read-write lock.
73
74       EPERM  The caller does not have the privilege to perform the operation.
75
76       These functions shall not return an error code of [EINTR].
77
78       The following sections are informative.
79

EXAMPLES

81       None.
82

APPLICATION USAGE

84       Applications  using  these and related read-write lock functions may be
85       subject to priority inversion, as discussed  in  the  Base  Definitions
86       volume of POSIX.1‐2017, Section 3.291, Priority Inversion.
87

RATIONALE

89       If  an  implementation  detects  that the value specified by the rwlock
90       argument to pthread_rwlock_destroy() does not refer to  an  initialized
91       read-write lock object, it is recommended that the function should fail
92       and report an [EINVAL] error.
93
94       If an implementation detects that the value specified by the attr argu‐
95       ment  to  pthread_rwlock_init()  does not refer to an initialized read-
96       write lock attributes object,  it  is  recommended  that  the  function
97       should fail and report an [EINVAL] error.
98
99       If  an  implementation  detects  that the value specified by the rwlock
100       argument to pthread_rwlock_destroy() or pthread_rwlock_init() refers to
101       a locked read-write lock object, or detects that the value specified by
102       the rwlock argument to pthread_rwlock_init() refers to an already  ini‐
103       tialized  read-write  lock  object, it is recommended that the function
104       should fail and report an [EBUSY] error.
105

FUTURE DIRECTIONS

107       None.
108

SEE ALSO

110       pthread_rwlock_rdlock(), pthread_rwlock_timedrdlock(),
111       pthread_rwlock_timedwrlock(), pthread_rwlock_trywrlock(),
112       pthread_rwlock_unlock()
113
114       The Base Definitions volume of POSIX.1‐2017,  Section  3.291,  Priority
115       Inversion, <pthread.h>
116
118       Portions  of  this text are reprinted and reproduced in electronic form
119       from IEEE Std 1003.1-2017, Standard for Information Technology --  Por‐
120       table  Operating System Interface (POSIX), The Open Group Base Specifi‐
121       cations Issue 7, 2018 Edition, Copyright (C) 2018 by the  Institute  of
122       Electrical  and  Electronics Engineers, Inc and The Open Group.  In the
123       event of any discrepancy between this version and the original IEEE and
124       The  Open Group Standard, the original IEEE and The Open Group Standard
125       is the referee document. The original Standard can be  obtained  online
126       at http://www.opengroup.org/unix/online.html .
127
128       Any  typographical  or  formatting  errors that appear in this page are
129       most likely to have been introduced during the conversion of the source
130       files  to  man page format. To report such errors, see https://www.ker
131       nel.org/doc/man-pages/reporting_bugs.html .
132
133
134
135IEEE/The Open Group                  2017           PTHREAD_RWLOCK_DESTROY(3P)
Impressum