1PTHREAD_RWLOCKATTR_SETKIND_NLPi(b3r)ary Functions MaPnTuHaRlEAD_RWLOCKATTR_SETKIND_NP(3)
2
3
4

NAME

6       pthread_rwlockattr_setkind_np,  pthread_rwlockattr_getkind_np - set/get
7       the read-write lock kind of the thread read-write lock attribute object
8

SYNOPSIS

10       #include <pthread.h>
11
12       int pthread_rwlockattr_setkind_np(pthread_rwlockattr_t *attr,
13                                          int pref);
14       int pthread_rwlockattr_getkind_np(const pthread_rwlockattr_t *attr,
15                                          int *pref);
16
17       Compile and link with -pthread.
18
19   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
20
21       pthread_rwlockattr_setkind_np(), pthread_rwlockattr_getkind_np():
22           _XOPEN_SOURCE >= 500 || _POSIX_C_SOURCE >= 200809L
23

DESCRIPTION

25       The  pthread_rwlockattr_setkind_np()  function  sets  the  "lock  kind"
26       attribute  of  the read-write lock attribute object referred to by attr
27       to the value specified in pref.  The argument pref may be set to one of
28       the following:
29
30       PTHREAD_RWLOCK_PREFER_READER_NP
31              This  is  the  default.   A thread may hold multiple read locks;
32              that is, read locks are recursive.  According to The Single Unix
33              Specification,  the  behavior is unspecified when a reader tries
34              to place a lock, and there is no  write  lock  but  writers  are
35              waiting.   Giving  preference  to  the  reader,  as  is  set  by
36              PTHREAD_RWLOCK_PREFER_READER_NP, implies that  the  reader  will
37              receive  the  requested  lock,  even if a writer is waiting.  As
38              long as there are readers, the writer will be starved.
39
40       PTHREAD_RWLOCK_PREFER_WRITER_NP
41              This is intended as the write lock analog of PTHREAD_RWLOCK_PRE‐
42              FER_READER_NP.   This  is  ignored  by  glibc  because the POSIX
43              requirement to support recursive writer locks would  cause  this
44              option    to    create    trivial    deadlocks;    instead   use
45              PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP which  ensures  the
46              application  developer  will  not take recursive read locks thus
47              avoiding deadlocks.
48
49       PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP
50              Setting the lock kind to this avoids writer starvation  as  long
51              as any read locking is not done in a recursive fashion.
52
53       The  pthread_rwlockattr_getkind_np()  function returns the value of the
54       lock kind attribute of the read-write lock attribute object referred to
55       by attr in the pointer pref.
56

RETURN VALUE

58       On  success,  these functions return 0.  Given valid pointer arguments,
59       pthread_rwlockattr_getkind_np()    always    succeeds.     On    error,
60       pthread_rwlockattr_setkind_np() returns a nonzero error number.
61

ERRORS

63       EINVAL pref specifies an unsupported value.
64

VERSIONS

66       The pthread_rwlockattr_getkind_np() and pthread_rwlockattr_setkind_np()
67       functions first appeared in glibc 2.1.
68

CONFORMING TO

70       These functions are non-standard GNU extensions; hence the suffix "_np"
71       (nonportable) in the names.
72

SEE ALSO

74       pthreads(7)
75

COLOPHON

77       This  page  is  part of release 5.04 of the Linux man-pages project.  A
78       description of the project, information about reporting bugs,  and  the
79       latest     version     of     this    page,    can    be    found    at
80       https://www.kernel.org/doc/man-pages/.
81
82
83
84Linux Programmer's Manual         2019-03-06  PTHREAD_RWLOCKATTR_SETKIND_NP(3)
Impressum