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

LIBRARY

10       POSIX threads library (libpthread, -lpthread)
11

SYNOPSIS

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

DESCRIPTION

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

RETURN VALUE

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

ERRORS

65       EINVAL pref specifies an unsupported value.
66

STANDARDS

68       GNU; hence the suffix "_np" (nonportable) in the names.
69

HISTORY

71       glibc 2.1.
72

SEE ALSO

74       pthreads(7)
75
76
77
78Linux man-pages 6.04              2023-03-30  pthread_rwlockattr_setkind_np(3)
Impressum