1PTHREAD_RWLOCK_TRYWRLOCK(3P)POSIX Programmer's ManuaPlTHREAD_RWLOCK_TRYWRLOCK(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_trywrlock, pthread_rwlock_wrlock  -  lock  a  read-write
13       lock object for writing
14

SYNOPSIS

16       #include <pthread.h>
17
18       int pthread_rwlock_trywrlock(pthread_rwlock_t *rwlock);
19       int pthread_rwlock_wrlock(pthread_rwlock_t *rwlock);
20
21

DESCRIPTION

23       The  pthread_rwlock_trywrlock()  function shall apply a write lock like
24       the pthread_rwlock_wrlock() function, with the exception that the func‐
25       tion  shall  fail  if any thread currently holds rwlock (for reading or
26       writing).
27
28       The pthread_rwlock_wrlock() function shall apply a write  lock  to  the
29       read-write  lock  referenced by rwlock. The calling thread acquires the
30       write lock if no other thread (reader or writer) holds  the  read-write
31       lock rwlock. Otherwise, the thread shall block until it can acquire the
32       lock. The calling thread may deadlock if at the time the call  is  made
33       it holds the read-write lock (whether a read or write lock).
34
35       Implementations  may favor writers over readers to avoid writer starva‐
36       tion.
37
38       Results are undefined if any of these  functions  are  called  with  an
39       uninitialized read-write lock.
40
41       If  a signal is delivered to a thread waiting for a read-write lock for
42       writing, upon return from the signal handler the thread resumes waiting
43       for the read-write lock for writing as if it was not interrupted.
44

RETURN VALUE

46       The  pthread_rwlock_trywrlock()  function shall return zero if the lock
47       for writing on the read-write  lock  object  referenced  by  rwlock  is
48       acquired.  Otherwise, an error number shall be returned to indicate the
49       error.
50
51       If successful, the pthread_rwlock_wrlock() function shall return  zero;
52       otherwise, an error number shall be returned to indicate the error.
53

ERRORS

55       The pthread_rwlock_trywrlock() function shall fail if:
56
57       EBUSY  The read-write lock could not be acquired for writing because it
58              was already locked for reading or writing.
59
60
61       The pthread_rwlock_trywrlock()  and  pthread_rwlock_wrlock()  functions
62       may fail if:
63
64       EINVAL The  value  specified by rwlock does not refer to an initialized
65              read-write lock object.
66
67
68       The pthread_rwlock_wrlock() function may fail if:
69
70       EDEADLK
71              The current thread already owns the read-write lock for  writing
72              or reading.
73
74
75       These functions shall not return an error code of [EINTR].
76
77       The following sections are informative.
78

EXAMPLES

80       None.
81

APPLICATION USAGE

83       Applications  using  these  functions may be subject to priority inver‐
84       sion,   as   discussed   in   the   Base    Definitions    volume    of
85       IEEE Std 1003.1-2001, Section 3.285, Priority Inversion.
86

RATIONALE

88       None.
89

FUTURE DIRECTIONS

91       None.
92

SEE ALSO

94       pthread_rwlock_destroy(), pthread_rwlock_rdlock(), pthread_rwlock_time‐
95       drdlock(),  pthread_rwlock_timedwrlock(),   pthread_rwlock_tryrdlock(),
96       pthread_rwlock_unlock(),     the    Base    Definitions    volume    of
97       IEEE Std 1003.1-2001, <pthread.h>
98
100       Portions of this text are reprinted and reproduced in  electronic  form
101       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
102       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
103       Specifications  Issue  6,  Copyright  (C) 2001-2003 by the Institute of
104       Electrical and Electronics Engineers, Inc and The Open  Group.  In  the
105       event of any discrepancy between this version and the original IEEE and
106       The Open Group Standard, the original IEEE and The Open Group  Standard
107       is  the  referee document. The original Standard can be obtained online
108       at http://www.opengroup.org/unix/online.html .
109
110
111
112IEEE/The Open Group                  2003         PTHREAD_RWLOCK_TRYWRLOCK(3P)
Impressum