209 lines
4.8 KiB
HTML
209 lines
4.8 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of PTHREAD_RWLOCKATTR_SETKIND_NP</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>PTHREAD_RWLOCKATTR_SETKIND_NP</H1>
|
|
Section: C Library Functions (3)<BR>Updated: 2019-03-06<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
pthread_rwlockattr_setkind_np, pthread_rwlockattr_getkind_np - set/get
|
|
the read-write lock kind of the thread read-write lock attribute object
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
<PRE>
|
|
<B>#include <<A HREF="file:///usr/include/pthread.h">pthread.h</A>></B>
|
|
|
|
<B>int pthread_rwlockattr_setkind_np(pthread_rwlockattr_t *</B><I>attr</I><B>,</B>
|
|
<B> int </B><I>pref</I><B>);</B>
|
|
<B>int pthread_rwlockattr_getkind_np(const pthread_rwlockattr_t *</B><I>attr</I><B>,</B>
|
|
<B> int *</B><I>pref</I><B>);</B>
|
|
|
|
Compile and link with <I>-pthread</I>.
|
|
|
|
</PRE>
|
|
|
|
|
|
Feature Test Macro Requirements for glibc (see
|
|
<B><A HREF="/cgi-bin/man/man2html?7+feature_test_macros">feature_test_macros</A></B>(7)):
|
|
|
|
|
|
<P>
|
|
|
|
<B>pthread_rwlockattr_setkind_np</B>(),
|
|
|
|
<B>pthread_rwlockattr_getkind_np</B>():
|
|
|
|
<BR>
|
|
|
|
<DL COMPACT><DT id="1"><DD>
|
|
|
|
_XOPEN_SOURCE >= 500 || _POSIX_C_SOURCE >= 200809L
|
|
</DL>
|
|
|
|
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
The
|
|
<B>pthread_rwlockattr_setkind_np</B>()
|
|
|
|
function sets the "lock kind" attribute of the
|
|
read-write lock attribute object referred to by
|
|
<I>attr</I>
|
|
|
|
to the value specified in
|
|
<I>pref</I>.
|
|
|
|
The argument
|
|
<I>pref</I>
|
|
|
|
may be set to one of the following:
|
|
<DL COMPACT>
|
|
<DT id="2"><B>PTHREAD_RWLOCK_PREFER_READER_NP</B>
|
|
|
|
<DD>
|
|
This is the default.
|
|
A thread may hold multiple read locks; that is, read locks are recursive.
|
|
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
|
|
waiting.
|
|
Giving preference to the reader, as is set by
|
|
<B>PTHREAD_RWLOCK_PREFER_READER_NP</B>,
|
|
|
|
implies that the reader will receive the requested lock, even if
|
|
a writer is waiting.
|
|
As long as there are readers, the writer will be
|
|
starved.
|
|
<DT id="3"><B>PTHREAD_RWLOCK_PREFER_WRITER_NP</B>
|
|
|
|
<DD>
|
|
This is intended as the write lock analog of
|
|
<B>PTHREAD_RWLOCK_PREFER_READER_NP</B>.
|
|
|
|
This is ignored by glibc because the POSIX requirement to support
|
|
recursive writer locks would cause this option to create trivial
|
|
deadlocks; instead use
|
|
<B>PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP</B>
|
|
|
|
which ensures the application developer will not take recursive
|
|
read locks thus avoiding deadlocks.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<DT id="4"><B>PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP</B>
|
|
|
|
<DD>
|
|
Setting the lock kind to this
|
|
avoids writer starvation as long as any read locking is not done in a
|
|
recursive fashion.
|
|
</DL>
|
|
<P>
|
|
|
|
The
|
|
<B>pthread_rwlockattr_getkind_np</B>()
|
|
|
|
function returns the value of the lock kind attribute of the
|
|
read-write lock attribute object referred to by
|
|
<I>attr</I>
|
|
|
|
in the pointer
|
|
<I>pref</I>.
|
|
|
|
<A NAME="lbAE"> </A>
|
|
<H2>RETURN VALUE</H2>
|
|
|
|
On success, these functions return 0.
|
|
Given valid pointer arguments,
|
|
<B>pthread_rwlockattr_getkind_np</B>()
|
|
|
|
always succeeds.
|
|
On error,
|
|
<B>pthread_rwlockattr_setkind_np</B>()
|
|
|
|
returns a nonzero error number.
|
|
<A NAME="lbAF"> </A>
|
|
<H2>ERRORS</H2>
|
|
|
|
<DL COMPACT>
|
|
<DT id="5"><B>EINVAL</B>
|
|
|
|
<DD>
|
|
<I>pref</I>
|
|
|
|
specifies an unsupported value.
|
|
</DL>
|
|
<A NAME="lbAG"> </A>
|
|
<H2>VERSIONS</H2>
|
|
|
|
The
|
|
<B>pthread_rwlockattr_getkind_np</B>()
|
|
|
|
and
|
|
<B>pthread_rwlockattr_setkind_np</B>()
|
|
|
|
functions first appeared in glibc 2.1.
|
|
<A NAME="lbAH"> </A>
|
|
<H2>CONFORMING TO</H2>
|
|
|
|
These functions are non-standard GNU extensions;
|
|
hence the suffix "_np" (nonportable) in the names.
|
|
<A NAME="lbAI"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?7+pthreads">pthreads</A></B>(7)
|
|
|
|
<A NAME="lbAJ"> </A>
|
|
<H2>COLOPHON</H2>
|
|
|
|
This page is part of release 5.05 of the Linux
|
|
<I>man-pages</I>
|
|
|
|
project.
|
|
A description of the project,
|
|
information about reporting bugs,
|
|
and the latest version of this page,
|
|
can be found at
|
|
<A HREF="https://www.kernel.org/doc/man-pages/.">https://www.kernel.org/doc/man-pages/.</A>
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="6"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="7"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="8"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DT id="9"><A HREF="#lbAE">RETURN VALUE</A><DD>
|
|
<DT id="10"><A HREF="#lbAF">ERRORS</A><DD>
|
|
<DT id="11"><A HREF="#lbAG">VERSIONS</A><DD>
|
|
<DT id="12"><A HREF="#lbAH">CONFORMING TO</A><DD>
|
|
<DT id="13"><A HREF="#lbAI">SEE ALSO</A><DD>
|
|
<DT id="14"><A HREF="#lbAJ">COLOPHON</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:05:53 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|