]>
Commit | Line | Data |
---|---|---|
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 | |
26 | pthread_rwlockattr_setkind_np, pthread_rwlockattr_getkind_np \- set/get | |
27 | the 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 | |
38 | Compile and link with \fI\-pthread\fP. | |
39 | .SH DESCRIPTION | |
40 | The | |
41 | .BR pthread_rwlockattr_setkind_np () | |
42 | function | |
43 | sets the kind of read-write lock of the | |
44 | thread read-write lock attribute object referred to by | |
45 | .I attr | |
46 | to the value specified with | |
47 | .IR pref . | |
48 | The argument | |
49 | .I pref | |
50 | may be set to | |
51 | .IR PTHREAD_RWLOCK_PREFER_READER_NP , | |
52 | .IR PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP , | |
53 | or | |
54 | .IR PTHREAD_RWLOCK_PREFER_WRITER_NP . | |
55 | The default lock setting is | |
56 | .IR PTHREAD_RWLOCK_PREFER_READER_NP . | |
57 | A thread may hold multiple read locks, i.e. read locks are recursive. | |
58 | According to The Single Unix Specification, the behavior is unspecified when a | |
59 | reader tries to place a lock, and there is no write lock but writers are | |
60 | waiting. Giving preference to the reader, as is set by default with the | |
61 | .IR PTHREAD_RWLOCK_PREFER_READER_NP value | |
62 | implies that the reader will receive the requested lock, even if | |
63 | a writer is waiting. As long as there are readers the writer will be | |
64 | starved. Setting the kind to | |
65 | .IR PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP , | |
66 | avoids writer starvation as long as any read locking is not done in a | |
67 | recursive fashion. | |
68 | ||
69 | The | |
70 | .BR pthread_rwlockattr_getkind_np () | |
71 | function | |
72 | returns the value of the read-write lock attribute of the | |
73 | thread read-write lock attribute object referred to by | |
74 | .IR attr | |
75 | in the pointer | |
76 | .IR pref . | |
77 | .SH RETURN VALUE | |
78 | On success, these functions return 0; | |
79 | on error, | |
80 | .BR pthread_rwlockattr_setkind_np () | |
81 | returns a non-zero error number. | |
82 | .SH ERRORS | |
83 | .TP | |
84 | .BR EINVAL | |
85 | .I pref | |
86 | is set to an unsupported value. | |
87 | .SH BUGS | |
88 | Setting the value read-write lock kind to | |
89 | .IR PTHREAD_RWLOCK_PREFER_WRITER_NP , | |
90 | results in the same behavior as setting the value to | |
91 | .IR PTHREAD_RWLOCK_PREFER_READER_NP . | |
92 | As long as a reader thread holds the lock the thread holding a | |
93 | write lock will be starved. Setting the kind value to | |
94 | .IR PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP , | |
95 | allows the writer to run. However, the writer may not be | |
96 | recursive as is implied by the name. See | |
97 | http://sourceware.org/bugzilla/show_bug.cgi?id=7057 | |
98 | .SH CONFORMING TO | |
99 | These functions are non-standard GNU extensions; | |
100 | hence the suffix "_np" (non-portable) in the names. | |
101 | .SH SEE ALSO | |
102 | .BR pthreads (7) |