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

NAME

6       pthread_rwlock_destroy,  pthread_rwlock_init - destroy and initialize a
7       read-write lock object
8

SYNOPSIS

10       #include <pthread.h>
11
12       int pthread_rwlock_destroy(pthread_rwlock_t *rwlock);
13       int pthread_rwlock_init(pthread_rwlock_t *restrict rwlock,
14              const pthread_rwlockattr_t *restrict attr);
15
16

DESCRIPTION

18       The pthread_rwlock_destroy() function shall destroy the read-write lock
19       object referenced by rwlock and release any resources used by the lock.
20       The effect of subsequent use of the lock is undefined until the lock is
21       reinitialized  by another call to pthread_rwlock_init(). An implementa‐
22       tion may cause pthread_rwlock_destroy() to set the object referenced by
23       rwlock    to    an    invalid   value.   Results   are   undefined   if
24       pthread_rwlock_destroy()  is  called  when  any  thread  holds  rwlock.
25       Attempting to destroy an uninitialized read-write lock results in unde‐
26       fined behavior.
27
28       The  pthread_rwlock_init()  function  shall  allocate   any   resources
29       required  to  use the read-write lock referenced by rwlock and initial‐
30       izes the lock to an unlocked state with attributes referenced by  attr.
31       If  attr is NULL, the default read-write lock attributes shall be used;
32       the effect is the same as passing the address of a  default  read-write
33       lock attributes object. Once initialized, the lock can be used any num‐
34       ber of times without being  reinitialized.  Results  are  undefined  if
35       pthread_rwlock_init() is called specifying an already initialized read-
36       write lock. Results are undefined if a read-write lock is used  without
37       first being initialized.
38
39       If  the  pthread_rwlock_init() function fails, rwlock shall not be ini‐
40       tialized and the contents of rwlock are undefined.
41
42       Only the object referenced by rwlock may be used  for  performing  syn‐
43       chronization. The result of referring to copies of that object in calls
44       to          pthread_rwlock_destroy(),          pthread_rwlock_rdlock(),
45       pthread_rwlock_timedrdlock(),             pthread_rwlock_timedwrlock(),
46       pthread_rwlock_tryrdlock(),                 pthread_rwlock_trywrlock(),
47       pthread_rwlock_unlock(), or pthread_rwlock_wrlock() is undefined.
48

RETURN VALUE

50       If  successful,  the pthread_rwlock_destroy() and pthread_rwlock_init()
51       functions shall return  zero;  otherwise,  an  error  number  shall  be
52       returned to indicate the error.
53
54       The  [EBUSY]  and [EINVAL] error checks, if implemented, act as if they
55       were performed immediately at the beginning of processing for the func‐
56       tion  and  caused  an  error return prior to modifying the state of the
57       read-write lock specified by rwlock.
58

ERRORS

60       The pthread_rwlock_destroy() function may fail if:
61
62       EBUSY  The implementation has detected an attempt to destroy the object
63              referenced by rwlock while it is locked.
64
65       EINVAL The value specified by rwlock is invalid.
66
67
68       The pthread_rwlock_init() function shall fail if:
69
70       EAGAIN The system lacked the necessary resources (other than memory) to
71              initialize another read-write lock.
72
73       ENOMEM Insufficient memory exists to initialize the read-write lock.
74
75       EPERM  The caller does not have the privilege to perform the operation.
76
77
78       The pthread_rwlock_init() function may fail if:
79
80       EBUSY  The implementation has detected an attempt to  reinitialize  the
81              object  referenced  by  rwlock, a previously initialized but not
82              yet destroyed read-write lock.
83
84       EINVAL The value specified by attr is invalid.
85
86
87       These functions shall not return an error code of [EINTR].
88
89       The following sections are informative.
90

EXAMPLES

92       None.
93

APPLICATION USAGE

95       Applications using these and related read-write lock functions  may  be
96       subject  to  priority  inversion,  as discussed in the Base Definitions
97       volume of IEEE Std 1003.1-2001, Section 3.285, Priority Inversion.
98

RATIONALE

100       None.
101

FUTURE DIRECTIONS

103       None.
104

SEE ALSO

106       pthread_rwlock_rdlock()      ,      pthread_rwlock_timedrdlock()      ,
107       pthread_rwlock_timedwrlock()     ,     pthread_rwlock_tryrdlock()     ,
108       pthread_rwlock_trywrlock()      ,       pthread_rwlock_unlock()       ,
109       pthread_rwlock_wrlock()    ,    the    Base   Definitions   volume   of
110       IEEE Std 1003.1-2001, <pthread.h>
111
113       Portions of this text are reprinted and reproduced in  electronic  form
114       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
115       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
116       Specifications  Issue  6,  Copyright  (C) 2001-2003 by the Institute of
117       Electrical and Electronics Engineers, Inc and The Open  Group.  In  the
118       event of any discrepancy between this version and the original IEEE and
119       The Open Group Standard, the original IEEE and The Open Group  Standard
120       is  the  referee document. The original Standard can be obtained online
121       at http://www.opengroup.org/unix/online.html .
122
123
124
125IEEE/The Open Group                  2003            PTHREAD_RWLOCK_DESTROY(P)
Impressum