📄 pthread_mutexattr_setprotocol.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta name="generator" content="HTML Tidy, see www.w3.org"><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 --><!-- Copyright (c) 2001-2003 The Open Group, All Rights Reserved --><title>pthread_mutexattr_getprotocol</title></head><body bgcolor="white"><script type="text/javascript" language="JavaScript" src="../jscript/codes.js"></script><basefont size="3"> <a name="pthread_mutexattr_getprotocol"></a> <a name="tag_03_546"></a><!-- pthread_mutexattr_getprotocol --> <!--header start--><center><font size="2">The Open Group Base Specifications Issue 6<br>IEEE Std 1003.1, 2003 Edition<br>Copyright © 2001-2003 The IEEE and The Open Group, All Rights reserved.</font></center><!--header end--><hr size="2" noshade><h4><a name="tag_03_546_01"></a>NAME</h4><blockquote>pthread_mutexattr_getprotocol, pthread_mutexattr_setprotocol - get and set the protocol attribute of the mutexattributes object (<b>REALTIME THREADS</b>)</blockquote><h4><a name="tag_03_546_02"></a>SYNOPSIS</h4><blockquote class="synopsis"><div class="box"><code><tt><sup>[<a href="javascript:open_code('THR')">THR</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> #include <<a href="../basedefs/pthread.h.html">pthread.h</a>><br><br><tt><sup>[<a href="javascript:open_code('TPP')">TPP|TPI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> int pthread_mutexattr_getprotocol(const pthread_mutexattr_t *<br> restrict</tt> <i>attr</i><tt>, int *restrict</tt> <i>protocol</i><tt>);<br> int pthread_mutexattr_setprotocol(pthread_mutexattr_t *</tt><i>attr</i><tt>,<br> int</tt> <i>protocol</i><tt>); <img src="../images/opt-end.gif" alt="[Option End]" border="0"></tt><br> <img src="../images/opt-end.gif" alt="[Option End]" border="0"></tt></code></div><tt><br></tt></blockquote><h4><a name="tag_03_546_03"></a>DESCRIPTION</h4><blockquote><p>The <i>pthread_mutexattr_getprotocol</i>() and <i>pthread_mutexattr_setprotocol</i>() functions, respectively, shall get and setthe protocol attribute of a mutex attributes object pointed to by <i>attr</i> which was previously created by the function <a href="../functions/pthread_mutexattr_init.html"><i>pthread_mutexattr_init</i>()</a>.</p><p>The <i>protocol</i> attribute defines the protocol to be followed in utilizing mutexes. The value of <i>protocol</i> may be oneof:</p><p><br>PTHREAD_PRIO_NONE<br><sup>[<a href="javascript:open_code('TPI')">TPI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"><br>PTHREAD_PRIO_INHERIT<br><img src="../images/opt-end.gif" alt="[Option End]" border="0"><br><sup>[<a href="javascript:open_code('TPP')">TPP</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"><br>PTHREAD_PRIO_PROTECT<br><img src="../images/opt-end.gif" alt="[Option End]" border="0"><br></p><p>which are defined in the <a href="../basedefs/pthread.h.html"><i><pthread.h></i></a> header.</p><p>When a thread owns a mutex with the PTHREAD_PRIO_NONE <i>protocol</i> attribute, its priority and scheduling shall not beaffected by its mutex ownership.</p><p><sup>[<a href="javascript:open_code('TPI')">TPI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">When a thread is blocking higher priority threads because of owning one or more mutexes with the PTHREAD_PRIO_INHERIT<i>protocol</i> attribute, it shall execute at the higher of its priority or the priority of the highest priority thread waiting onany of the mutexes owned by this thread and initialized with this protocol. <img src="../images/opt-end.gif" alt="[Option End]"border="0"></p><p><sup>[<a href="javascript:open_code('TPP')">TPP</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">When a thread owns one or more mutexes initialized with the PTHREAD_PRIO_PROTECT protocol, it shall execute at the higher of itspriority or the highest of the priority ceilings of all the mutexes owned by this thread and initialized with this attribute,regardless of whether other threads are blocked on any of these mutexes or not. <img src="../images/opt-end.gif" alt="[Option End]"border="0"></p><p>While a thread is holding a mutex which has been initialized with the PTHREAD_PRIO_INHERIT or PTHREAD_PRIO_PROTECT protocolattributes, it shall not be subject to being moved to the tail of the scheduling queue at its priority in the event that itsoriginal priority is changed, such as by a call to <a href="../functions/sched_setparam.html"><i>sched_setparam</i>()</a>.Likewise, when a thread unlocks a mutex that has been initialized with the PTHREAD_PRIO_INHERIT or PTHREAD_PRIO_PROTECT protocolattributes, it shall not be subject to being moved to the tail of the scheduling queue at its priority in the event that itsoriginal priority is changed.</p><p>If a thread simultaneously owns several mutexes initialized with different protocols, it shall execute at the highest of thepriorities that it would have obtained by each of these protocols.</p><p><sup>[<a href="javascript:open_code('TPI')">TPI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">When a thread makes a call to <a href="../functions/pthread_mutex_lock.html"><i>pthread_mutex_lock</i>()</a>, the mutex wasinitialized with the protocol attribute having the value PTHREAD_PRIO_INHERIT, when the calling thread is blocked because the mutexis owned by another thread, that owner thread shall inherit the priority level of the calling thread as long as it continues to ownthe mutex. The implementation shall update its execution priority to the maximum of its assigned priority and all its inheritedpriorities. Furthermore, if this owner thread itself becomes blocked on another mutex, the same priority inheritance effect shallbe propagated to this other owner thread, in a recursive manner. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p></blockquote><h4><a name="tag_03_546_04"></a>RETURN VALUE</h4><blockquote><p>Upon successful completion, the <i>pthread_mutexattr_getprotocol</i>() and <i>pthread_mutexattr_setprotocol</i>() functionsshall return zero; otherwise, an error number shall be returned to indicate the error.</p></blockquote><h4><a name="tag_03_546_05"></a>ERRORS</h4><blockquote><p>The <i>pthread_mutexattr_setprotocol</i>() function shall fail if:</p><dl compact><dt>[ENOTSUP]</dt><dd>The value specified by <i>protocol</i> is an unsupported value.</dd></dl><p>The <i>pthread_mutexattr_getprotocol</i>() and <i>pthread_mutexattr_setprotocol</i>() functions may fail if:</p><dl compact><dt>[EINVAL]</dt><dd>The value specified by <i>attr</i> or <i>protocol</i> is invalid.</dd><dt>[EPERM]</dt><dd>The caller does not have the privilege to perform the operation.</dd></dl><p>These functions shall not return an error code of [EINTR].</p></blockquote><hr><div class="box"><em>The following sections are informative.</em></div><h4><a name="tag_03_546_06"></a>EXAMPLES</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_03_546_07"></a>APPLICATION USAGE</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_03_546_08"></a>RATIONALE</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_03_546_09"></a>FUTURE DIRECTIONS</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_03_546_10"></a>SEE ALSO</h4><blockquote><p><a href="pthread_cond_destroy.html"><i>pthread_cond_destroy</i>()</a> , <a href="pthread_create.html"><i>pthread_create</i>()</a> , <a href="pthread_mutex_destroy.html"><i>pthread_mutex_destroy</i>()</a> , theBase Definitions volume of IEEE Std 1003.1-2001, <a href="../basedefs/pthread.h.html"><i><pthread.h></i></a></p></blockquote><h4><a name="tag_03_546_11"></a>CHANGE HISTORY</h4><blockquote><p>First released in Issue 5. Included for alignment with the POSIX Threads Extension.</p><p>Marked as part of the Realtime Threads Feature Group.</p></blockquote><h4><a name="tag_03_546_12"></a>Issue 6</h4><blockquote><p>The <i>pthread_mutexattr_getprotocol</i>() and <i>pthread_mutexattr_setprotocol</i>() functions are marked as part of theThreads option and either the Thread Priority Protection or Thread Priority Inheritance options.</p><p>The [ENOSYS] error condition has been removed as stubs need not be provided if an implementation does not support the ThreadPriority Protection or Thread Priority Inheritance options.</p><p>The <b>restrict</b> keyword is added to the <i>pthread_mutexattr_getprotocol</i>() prototype for alignment with theISO/IEC 9899:1999 standard.</p></blockquote><div class="box"><em>End of informative text.</em></div><hr><hr size="2" noshade><center><font size="2"><!--footer start-->UNIX ® is a registered Trademark of The Open Group.<br>POSIX ® is a registered Trademark of The IEEE.<br>[ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href="../utilities/contents.html">XCU</a> | <a href="../functions/contents.html">XSH</a> | <a href="../xrat/contents.html">XRAT</a>]</font></center><!--footer end--><hr size="2" noshade></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -