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
11

NAME

13       pthread_rwlock_trywrlock, pthread_rwlock_wrlock  —  lock  a  read-write
14       lock object for writing
15

SYNOPSIS

17       #include <pthread.h>
18
19       int pthread_rwlock_trywrlock(pthread_rwlock_t *rwlock);
20       int pthread_rwlock_wrlock(pthread_rwlock_t *rwlock);
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
32       the lock. The calling thread may deadlock if at the time  the  call  is
33       made 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       The pthread_rwlock_wrlock() function may fail if:
61
62       EDEADLK
63              A deadlock condition was detected or the current thread  already
64              owns the read-write lock for writing or reading.
65
66       These functions shall not return an error code of [EINTR].
67
68       The following sections are informative.
69

EXAMPLES

71       None.
72

APPLICATION USAGE

74       Applications  using  these  functions may be subject to priority inver‐
75       sion, as discussed in the Base Definitions volume of POSIX.1‐2008, Sec‐
76       tion 3.287, Priority Inversion.
77

RATIONALE

79       If  an  implementation  detects  that the value specified by the rwlock
80       argument to pthread_rwlock_trywrlock() or pthread_rwlock_wrlock()  does
81       not  refer  to an initialized read-write lock object, it is recommended
82       that the function should fail and report an [EINVAL] error.
83

FUTURE DIRECTIONS

85       None.
86

SEE ALSO

88       pthread_rwlock_destroy(), pthread_rwlock_rdlock(), pthread_rwlock_time‐
89       drdlock(), pthread_rwlock_timedwrlock(), pthread_rwlock_unlock()
90
91       The  Base  Definitions  volume of POSIX.1‐2008, Section 3.287, Priority
92       Inversion, Section 4.11, Memory Synchronization, <pthread.h>
93
95       Portions of this text are reprinted and reproduced in  electronic  form
96       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
97       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
98       Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
99       cal and Electronics Engineers,  Inc  and  The  Open  Group.   (This  is
100       POSIX.1-2008  with  the  2013  Technical Corrigendum 1 applied.) In the
101       event of any discrepancy between this version and the original IEEE and
102       The  Open Group Standard, the original IEEE and The Open Group Standard
103       is the referee document. The original Standard can be  obtained  online
104       at http://www.unix.org/online.html .
105
106       Any  typographical  or  formatting  errors that appear in this page are
107       most likely to have been introduced during the conversion of the source
108       files  to  man page format. To report such errors, see https://www.ker
109       nel.org/doc/man-pages/reporting_bugs.html .
110
111
112
113IEEE/The Open Group                  2013         PTHREAD_RWLOCK_TRYWRLOCK(3P)
Impressum