2014-06-27 07:51:41 +00:00
|
|
|
.\"Copyright (c) 2010 Novell Inc., written by Robert Schweikert
|
|
|
|
.\"
|
2014-10-15 09:13:11 +00:00
|
|
|
.\" %%%LICENSE_START(VERBATIM)
|
2014-06-27 07:51:41 +00:00
|
|
|
.\" Permission is granted to make and distribute verbatim copies of this
|
|
|
|
.\" manual provided the copyright notice and this permission notice are
|
|
|
|
.\" preserved on all copies.
|
|
|
|
.\"
|
|
|
|
.\" Permission is granted to copy and distribute modified versions of this
|
2015-12-06 18:47:30 +00:00
|
|
|
.\" manual under the conditions for verbatim copying, provided that the
|
2014-06-27 07:51:41 +00:00
|
|
|
.\" entire resulting derived work is distributed under the terms of a
|
|
|
|
.\" permission notice identical to this one.
|
|
|
|
.\"
|
|
|
|
.\" Since the Linux kernel and libraries are constantly changing, this
|
|
|
|
.\" manual page may be incorrect or out-of-date. The author(s) assume no
|
|
|
|
.\" responsibility for errors or omissions, or for damages resulting from
|
|
|
|
.\" the use of the information contained herein. The author(s) may not
|
|
|
|
.\" have taken the same level of care in the production of this manual,
|
|
|
|
.\" which is licensed free of charge, as they might when working
|
|
|
|
.\" professionally.
|
|
|
|
.\"
|
|
|
|
.\" Formatted or processed versions of this manual, if unaccompanied by
|
|
|
|
.\" the source, must acknowledge the copyright and authors of this work.
|
2014-10-15 09:13:11 +00:00
|
|
|
.\" %%%LICENSE_END
|
2014-06-27 07:51:41 +00:00
|
|
|
.\"
|
memusage.1, memusagestat.1, pldd.1, accept.2, adjtimex.2, arch_prctl.2, bdflush.2, bpf.2, close.2, epoll_ctl.2, epoll_wait.2, execve.2, execveat.2, fanotify_init.2, fanotify_mark.2, fcntl.2, fsync.2, get_kernel_syms.2, getdomainname.2, getgroups.2, gethostname.2, getrandom.2, getrlimit.2, getrusage.2, getsid.2, getunwind.2, io_getevents.2, ioctl_fat.2, kexec_load.2, killpg.2, listxattr.2, lseek.2, madvise.2, memfd_create.2, mknod.2, mlock.2, modify_ldt.2, msgctl.2, msgget.2, msgop.2, readlink.2, readv.2, reboot.2, recvmmsg.2, rename.2, request_key.2, restart_syscall.2, sched_setaffinity.2, sched_setattr.2, sched_setparam.2, seccomp.2, select_tut.2, semctl.2, semget.2, semop.2, set_thread_area.2, seteuid.2, setgid.2, setpgid.2, setresuid.2, setreuid.2, setsid.2, setuid.2, shmctl.2, shmget.2, shmop.2, sigaction.2, sigprocmask.2, stat.2, symlink.2, syscall.2, sysctl.2, unlink.2, bindresvport.3, byteorder.3, dlopen.3, endian.3, error.3, ffs.3, fmemopen.3, getcwd.3, getlogin.3, getnetent.3, getprotoent.3, getservent.3, getumask.3, getutent.3, glob.3, isalpha.3, lio_listio.3, login.3, mbsinit.3, mbstowcs.3, mbtowc.3, mkstemp.3, nextup.3, ntp_gettime.3, posix_fallocate.3, posix_spawn.3, pthread_join.3, pthread_rwlockattr_setkind_np.3, random.3, rcmd.3, realpath.3, resolver.3, setjmp.3, setnetgrent.3, sigvec.3, strerror.3, strverscmp.3, system.3, toupper.3, towlower.3, towupper.3, wcstombs.3, wordexp.3, cciss.4, loop.4, mouse.4, random.4, core.5, group.5, hosts.5, resolv.conf.5, ascii.7, environ.7, epoll.7, glob.7, ip.7, mq_overview.7, packet.7, pipe.7, raw.7, sched.7, signal.7, socket.7, symlink.7, ld.so.8, sln.8: tstamp
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2016-10-08 10:53:47 +00:00
|
|
|
.TH PTHREAD_RWLOCKATTR_SETKIND_NP 3 2016-10-08 "Linux Programmer's Manual"
|
2014-06-27 07:51:41 +00:00
|
|
|
.SH NAME
|
2014-10-15 09:17:46 +00:00
|
|
|
pthread_rwlockattr_setkind_np, pthread_rwlockattr_getkind_np \- set/get
|
2014-06-27 07:51:41 +00:00
|
|
|
the read-write lock kind of the thread read-write lock attribute object
|
|
|
|
.SH SYNOPSIS
|
|
|
|
.nf
|
|
|
|
.B #include <pthread.h>
|
|
|
|
|
2014-10-14 07:14:27 +00:00
|
|
|
.BI "int pthread_rwlockattr_setkind_np(pthread_rwlockattr_t *" attr ,
|
|
|
|
.BI " int " pref );
|
|
|
|
.BI "int pthread_rwlockattr_getkind_np(const pthread_rwlockattr_t *" attr ,
|
|
|
|
.BI " int *" pref );
|
2014-06-27 07:51:41 +00:00
|
|
|
.sp
|
|
|
|
Compile and link with \fI\-pthread\fP.
|
2014-10-14 07:14:27 +00:00
|
|
|
.sp
|
|
|
|
.fi
|
|
|
|
.in -4n
|
|
|
|
Feature Test Macro Requirements for glibc (see
|
|
|
|
.BR feature_test_macros (7)):
|
|
|
|
.in
|
|
|
|
.sp
|
|
|
|
.BR pthread_rwlockattr_setkind_np (),
|
|
|
|
.BR pthread_rwlockattr_getkind_np ():
|
|
|
|
.br
|
|
|
|
.RS 4
|
|
|
|
.ad l
|
|
|
|
_XOPEN_SOURCE\ >=\ 500 || _POSIX_C_SOURCE >= 200809L
|
|
|
|
.RE
|
|
|
|
.ad
|
2014-06-27 07:51:41 +00:00
|
|
|
.SH DESCRIPTION
|
|
|
|
The
|
|
|
|
.BR pthread_rwlockattr_setkind_np ()
|
2014-10-14 07:14:27 +00:00
|
|
|
function sets the "lock kind" attribute of the
|
|
|
|
read-write lock attribute object referred to by
|
2014-06-27 07:51:41 +00:00
|
|
|
.I attr
|
2014-10-14 07:14:27 +00:00
|
|
|
to the value specified in
|
2014-06-27 07:51:41 +00:00
|
|
|
.IR pref .
|
|
|
|
The argument
|
|
|
|
.I pref
|
2014-10-14 07:14:27 +00:00
|
|
|
may be set to one of the following:
|
|
|
|
.TP
|
|
|
|
.B PTHREAD_RWLOCK_PREFER_READER_NP
|
|
|
|
This is the default.
|
2014-10-15 09:17:46 +00:00
|
|
|
A thread may hold multiple read locks; that is, read locks are recursive.
|
2014-06-27 07:51:41 +00:00
|
|
|
According to The Single Unix Specification, the behavior is unspecified when a
|
|
|
|
reader tries to place a lock, and there is no write lock but writers are
|
2014-10-14 07:14:27 +00:00
|
|
|
waiting.
|
|
|
|
Giving preference to the reader, as is set by
|
|
|
|
.BR PTHREAD_RWLOCK_PREFER_READER_NP ,
|
2014-06-27 07:51:41 +00:00
|
|
|
implies that the reader will receive the requested lock, even if
|
2014-10-14 07:14:27 +00:00
|
|
|
a writer is waiting.
|
|
|
|
As long as there are readers, the writer will be
|
|
|
|
starved.
|
|
|
|
.TP
|
|
|
|
.B PTHREAD_RWLOCK_PREFER_WRITER_NP
|
|
|
|
This is intended as the write lock analog of
|
|
|
|
.BR PTHREAD_RWLOCK_PREFER_READER_NP .
|
|
|
|
But see BUGS.
|
|
|
|
.TP
|
|
|
|
.B PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP
|
2014-10-15 09:17:46 +00:00
|
|
|
Setting the lock kind to this
|
2014-06-27 07:51:41 +00:00
|
|
|
avoids writer starvation as long as any read locking is not done in a
|
|
|
|
recursive fashion.
|
2014-10-14 07:14:27 +00:00
|
|
|
.PP
|
2014-06-27 07:51:41 +00:00
|
|
|
The
|
|
|
|
.BR pthread_rwlockattr_getkind_np ()
|
2014-10-14 07:14:27 +00:00
|
|
|
function returns the value of the lock kind attribute of the
|
|
|
|
read-write lock attribute object referred to by
|
2014-06-27 07:51:41 +00:00
|
|
|
.IR attr
|
|
|
|
in the pointer
|
|
|
|
.IR pref .
|
|
|
|
.SH RETURN VALUE
|
2014-10-14 07:14:27 +00:00
|
|
|
On success, these functions return 0.
|
|
|
|
Given valid pointer arguments,
|
|
|
|
.BR pthread_rwlockattr_getkind_np ()
|
|
|
|
always succeeds.
|
|
|
|
On error,
|
2014-06-27 07:51:41 +00:00
|
|
|
.BR pthread_rwlockattr_setkind_np ()
|
|
|
|
returns a non-zero error number.
|
|
|
|
.SH ERRORS
|
|
|
|
.TP
|
|
|
|
.BR EINVAL
|
|
|
|
.I pref
|
2014-10-14 07:14:27 +00:00
|
|
|
specifies an unsupported value.
|
2016-08-07 19:18:05 +00:00
|
|
|
.SH VERSIONS
|
|
|
|
The
|
|
|
|
.BR pthread_rwlockattr_getkind_np ()
|
|
|
|
and
|
|
|
|
.BR pthread_rwlockattr_setkind_np ()
|
|
|
|
functions first appeared in glibc 2.1.
|
|
|
|
.SH CONFORMING TO
|
|
|
|
These functions are non-standard GNU extensions;
|
|
|
|
hence the suffix "_np" (non-portable) in the names.
|
2014-06-27 07:51:41 +00:00
|
|
|
.SH BUGS
|
|
|
|
Setting the value read-write lock kind to
|
2014-10-14 07:14:27 +00:00
|
|
|
.BR PTHREAD_RWLOCK_PREFER_WRITER_NP
|
2014-06-27 07:51:41 +00:00
|
|
|
results in the same behavior as setting the value to
|
2014-10-14 07:14:27 +00:00
|
|
|
.BR PTHREAD_RWLOCK_PREFER_READER_NP .
|
2014-10-15 09:17:46 +00:00
|
|
|
As long as a reader thread holds the lock, the thread holding a
|
2014-10-14 07:14:27 +00:00
|
|
|
write lock will be starved.
|
|
|
|
Setting the lock kind to
|
|
|
|
.BR PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP
|
|
|
|
allows writers to run, but, as the name implies a writer
|
|
|
|
may not lock recursively.
|
|
|
|
.\" http://sourceware.org/bugzilla/show_bug.cgi?id=7057
|
2014-06-27 07:51:41 +00:00
|
|
|
.SH SEE ALSO
|
|
|
|
.BR pthreads (7)
|