]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/pthread_rwlockattr_setkind_np.3
pthread_rwlockattr_getkind_np.3: New link to pthread_rwlockattr_setkind_np(3)
[thirdparty/man-pages.git] / man3 / pthread_rwlockattr_setkind_np.3
CommitLineData
88e15474
RS
1.\"Copyright (c) 2010 Novell Inc., written by Robert Schweikert
2.\" <mtk.manpages@gmail.com>
3.\"
4.\" Permission is granted to make and distribute verbatim copies of this
5.\" manual provided the copyright notice and this permission notice are
6.\" preserved on all copies.
7.\"
8.\" Permission is granted to copy and distribute modified versions of this
9.\" manual under the conditions for verbatim copying, provided that the
10.\" entire resulting derived work is distributed under the terms of a
11.\" permission notice identical to this one.
12.\"
13.\" Since the Linux kernel and libraries are constantly changing, this
14.\" manual page may be incorrect or out-of-date. The author(s) assume no
15.\" responsibility for errors or omissions, or for damages resulting from
16.\" the use of the information contained herein. The author(s) may not
17.\" have taken the same level of care in the production of this manual,
18.\" which is licensed free of charge, as they might when working
19.\" professionally.
20.\"
21.\" Formatted or processed versions of this manual, if unaccompanied by
22.\" the source, must acknowledge the copyright and authors of this work.
23.\"
24.TH PTHREAD_RWLOCKATTR_SETKIND_NP 3 2010-06-09 "Linux Programmer's Manual"
25.SH NAME
26pthread_rwlockattr_setkind_np, pthread_rwlockattr_getkind_np \- set/get
27the read-write lock kind of the thread read-write lock attribute object
28.SH SYNOPSIS
29.nf
30.B #define _XOPEN_SOURCE 500
31.B #include <pthread.h>
32
33.BI "int pthread_rwlockattr_setkind_np (pthread_rwlockattr_t *" attr ,
34.BI " int" pref);
35.BI "int pthread_rwlockattr_getkind_np (const pthread_rwlockattr_t *" attr ,
36.BI " int *" pref);
37.sp
38Compile and link with \fI\-pthread\fP.
39.SH DESCRIPTION
40The
41.BR pthread_rwlockattr_setkind_np ()
42function
43sets the kind of read-write lock of the
44thread read-write lock attribute object referred to by
45.I attr
46to the value specified with
47.IR pref .
48The argument
49.I pref
50may be set to
51.IR PTHREAD_RWLOCK_PREFER_READER_NP ,
52.IR PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP ,
53or
54.IR PTHREAD_RWLOCK_PREFER_WRITER_NP .
55The default lock setting is
56.IR PTHREAD_RWLOCK_PREFER_READER_NP .
57A thread may hold multiple read locks, i.e. read locks are recursive.
58According to The Single Unix Specification, the behavior is unspecified when a
59reader tries to place a lock, and there is no write lock but writers are
60waiting. Giving preference to the reader, as is set by default with the
61.IR PTHREAD_RWLOCK_PREFER_READER_NP value
62implies that the reader will receive the requested lock, even if
63a writer is waiting. As long as there are readers the writer will be
64starved. Setting the kind to
65.IR PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP ,
66avoids writer starvation as long as any read locking is not done in a
67recursive fashion.
68
69The
70.BR pthread_rwlockattr_getkind_np ()
71function
72returns the value of the read-write lock attribute of the
73thread read-write lock attribute object referred to by
74.IR attr
75in the pointer
76.IR pref .
77.SH RETURN VALUE
78On success, these functions return 0;
79on error,
80.BR pthread_rwlockattr_setkind_np ()
81returns a non-zero error number.
82.SH ERRORS
83.TP
84.BR EINVAL
85.I pref
86is set to an unsupported value.
87.SH BUGS
88Setting the value read-write lock kind to
89.IR PTHREAD_RWLOCK_PREFER_WRITER_NP ,
90results in the same behavior as setting the value to
91.IR PTHREAD_RWLOCK_PREFER_READER_NP .
92As long as a reader thread holds the lock the thread holding a
93write lock will be starved. Setting the kind value to
94.IR PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP ,
95allows the writer to run. However, the writer may not be
96recursive as is implied by the name. See
97http://sourceware.org/bugzilla/show_bug.cgi?id=7057
98.SH CONFORMING TO
99These functions are non-standard GNU extensions;
100hence the suffix "_np" (non-portable) in the names.
101.SH SEE ALSO
102.BR pthreads (7)