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

DESCRIPTION

22       The  pthread_rwlock_trywrlock()  function shall apply a write lock like
23       the pthread_rwlock_wrlock() function, with the exception that the func‐
24       tion  shall  fail  if any thread currently holds rwlock (for reading or
25       writing).
26
27       The pthread_rwlock_wrlock() function shall apply a write  lock  to  the
28       read-write lock referenced by rwlock.  The calling thread shall acquire
29       the write lock if no thread (reader or  writer)  holds  the  read-write
30       lock  rwlock.   Otherwise,  if another thread holds the read-write lock
31       rwlock, the calling thread shall block until it can acquire  the  lock.
32       If  a  deadlock condition occurs or the calling thread already owns the
33       read-write lock for writing or reading, the call shall either  deadlock
34       or return [EDEADLK].
35
36       Results  are  undefined  if  any  of these functions are called with an
37       uninitialized read-write lock.
38
39       If a signal is delivered to a thread waiting for a read-write lock  for
40       writing, upon return from the signal handler the thread resumes waiting
41       for the read-write lock for writing as if it was not interrupted.
42

RETURN VALUE

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

ERRORS

53       The pthread_rwlock_trywrlock() function shall fail if:
54
55       EBUSY  The read-write lock could not be acquired for writing because it
56              was already locked for reading or writing.
57
58       The pthread_rwlock_wrlock() function may fail if:
59
60       EDEADLK
61              A  deadlock condition was detected or the current thread already
62              owns the read-write lock for writing or reading.
63
64       These functions shall not return an error code of [EINTR].
65
66       The following sections are informative.
67

EXAMPLES

69       None.
70

APPLICATION USAGE

72       Applications using these functions may be subject  to  priority  inver‐
73       sion, as discussed in the Base Definitions volume of POSIX.1‐2017, Sec‐
74       tion 3.291, Priority Inversion.
75

RATIONALE

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

FUTURE DIRECTIONS

83       None.
84

SEE ALSO

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