1PTHREAD_RWLOCK_TRYWRLOCK(P)POSIX Programmer's ManualPTHREAD_RWLOCK_TRYWRLOCK(P)
2
3
4

NAME

6       pthread_rwlock_trywrlock,  pthread_rwlock_wrlock  -  lock  a read-write
7       lock object for writing
8

SYNOPSIS

10       #include <pthread.h>
11
12       int pthread_rwlock_trywrlock(pthread_rwlock_t *rwlock);
13       int pthread_rwlock_wrlock(pthread_rwlock_t *rwlock);
14
15

DESCRIPTION

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

RETURN VALUE

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

ERRORS

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

EXAMPLES

74       None.
75

APPLICATION USAGE

77       Applications using these functions may be subject  to  priority  inver‐
78       sion,    as    discussed    in   the   Base   Definitions   volume   of
79       IEEE Std 1003.1-2001, Section 3.285, Priority Inversion.
80

RATIONALE

82       None.
83

FUTURE DIRECTIONS

85       None.
86

SEE ALSO

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