man-pages/man3/pthread_mutexattr_getpshared.3.html
2021-03-31 01:06:50 +01:00

156 lines
3.9 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of PTHREAD_MUTEXATTR_GETPSHARED</TITLE>
</HEAD><BODY>
<H1>PTHREAD_MUTEXATTR_GETPSHARED</H1>
Section: Linux Programmer's Manual (3)<BR>Updated: 2017-09-13<BR><A HREF="#index">Index</A>
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
pthread_mutexattr_getpshared, pthread_mutexattr_setpshared - get/set
process-shared mutex attribute
<A NAME="lbAC">&nbsp;</A>
<H2>SYNOPSIS</H2>
<PRE>
<B>#include &lt;<A HREF="file:///usr/include/pthread.h">pthread.h</A>&gt;</B>
<B>int pthread_mutexattr_getpshared(const pthread_mutexattr_t *</B><I>attr</I><B>,</B>
<B> int *</B><I>pshared</I><B>);</B>
<B>int pthread_mutexattr_setpshared(pthread_mutexattr_t *</B><I>attr</I><B>,</B>
<B> int </B><I>pshared</I><B>);</B>
</PRE>
<P>
Compile and link with <I>-pthread</I>.
<A NAME="lbAD">&nbsp;</A>
<H2>DESCRIPTION</H2>
These functions get and set the process-shared attribute
in a mutex attributes object.
This attribute must be appropriately set to ensure correct,
efficient operation of a mutex created using this attributes object.
<P>
The process-shared attribute can have one of the following values:
<DL COMPACT>
<DT id="1"><B>PTHREAD_PROCESS_PRIVATE</B>
<DD>
Mutexes created with this attributes object are to be shared
only among threads in the same process that initialized the mutex.
This is the default value for the process-shared mutex attribute.
<DT id="2"><B>PTHREAD_PROCESS_SHARED</B>
<DD>
Mutexes created with this attributes object can be shared between
any threads that have access to the memory containing the object,
including threads in different processes.
</DL>
<P>
<B>pthread_mutexattr_getpshared</B>()
places the value of the process-shared attribute of
the mutex attributes object referred to by
<I>attr</I>
in the location pointed to by
<I>pshared</I>.
<P>
<B>pthread_mutexattr_setpshared</B>()
sets the value of the process-shared attribute of
the mutex attributes object referred to by
<I>attr</I>
to the value specified in
<B>pshared</B>.
<P>
If
<I>attr</I>
does not refer to an initialized mutex attributes object,
the behavior is undefined.
<A NAME="lbAE">&nbsp;</A>
<H2>RETURN VALUE</H2>
On success, these functions return 0.
On error, they return a positive error number.
<A NAME="lbAF">&nbsp;</A>
<H2>ERRORS</H2>
<B>pthread_mutexattr_setpshared</B>()
can fail with the following errors:
<DL COMPACT>
<DT id="3"><B>EINVAL</B>
<DD>
The value specified in
<I>pshared</I>
is invalid.
<DT id="4"><B>ENOTSUP</B>
<DD>
<I>pshared is</I>
<B>PTHREAD_PROCESS_SHARED</B>
but the implementation does not support process-shared mutexes.
</DL>
<A NAME="lbAG">&nbsp;</A>
<H2>CONFORMING TO</H2>
POSIX.1-2001, POSIX.1-2008.
<A NAME="lbAH">&nbsp;</A>
<H2>SEE ALSO</H2>
<B><A HREF="/cgi-bin/man/man2html?3+pthread_mutexattr_init">pthread_mutexattr_init</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?7+pthreads">pthreads</A></B>(7)
<A NAME="lbAI">&nbsp;</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">&nbsp;</A><H2>Index</H2>
<DL>
<DT id="5"><A HREF="#lbAB">NAME</A><DD>
<DT id="6"><A HREF="#lbAC">SYNOPSIS</A><DD>
<DT id="7"><A HREF="#lbAD">DESCRIPTION</A><DD>
<DT id="8"><A HREF="#lbAE">RETURN VALUE</A><DD>
<DT id="9"><A HREF="#lbAF">ERRORS</A><DD>
<DT id="10"><A HREF="#lbAG">CONFORMING TO</A><DD>
<DT id="11"><A HREF="#lbAH">SEE ALSO</A><DD>
<DT id="12"><A HREF="#lbAI">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>