pthread_setconcurrency.html 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  2. <HTML>
  3. <HEAD>
  4. <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8">
  5. <TITLE>&quot;PTHREAD_GETCONCURRENCY&quot;(P) manual page</TITLE>
  6. <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.3 (Linux)">
  7. <META NAME="CREATED" CONTENT="20050505;19162600">
  8. <META NAME="CHANGED" CONTENT="20050505;19223800">
  9. <!-- manual page source format generated by PolyglotMan v3.2, -->
  10. <!-- available at http://polyglotman.sourceforge.net/ -->
  11. </HEAD>
  12. <BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR">
  13. <H4>POSIX Threads for Windows – REFERENCE - <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4>
  14. <P><A HREF="index.html">Reference Index</A></P>
  15. <P><A HREF="#toc">Table of Contents</A></P>
  16. <H2><A HREF="#toc0" NAME="sect0">Name</A></H2>
  17. <P>pthread_getconcurrency, pthread_setconcurrency - get and set the
  18. level of concurrency
  19. </P>
  20. <H2><A HREF="#toc1" NAME="sect1">Synopsis</A></H2>
  21. <P><B>#include &lt;pthread.h&gt; </B>
  22. </P>
  23. <P><B>int pthread_getconcurrency(void);</B> <BR><B>int
  24. pthread_setconcurrency(int</B> <I>new_level</I><B>); </B>
  25. </P>
  26. <H2><A HREF="#toc2" NAME="sect2">Description</A></H2>
  27. <P>Unbound threads in a process may or may not be required to be
  28. simultaneously active. By default, the threads implementation ensures
  29. that a sufficient number of threads are active so that the process
  30. can continue to make progress. While this conserves system resources,
  31. it may not produce the most effective level of concurrency.
  32. </P>
  33. <P>The <B>pthread_setconcurrency</B> function allows an application
  34. to inform the threads implementation of its desired concurrency
  35. level, <I>new_level</I>. The actual level of concurrency provided by
  36. the implementation as a result of this function call is unspecified.
  37. </P>
  38. <P>If <I>new_level</I> is zero, it causes the implementation to
  39. maintain the concurrency level at its discretion as if
  40. <B>pthread_setconcurrency</B> had never been called.
  41. </P>
  42. <P>The <B>pthread_getconcurrency</B> function shall return the value
  43. set by a previous call to the <B>pthread_setconcurrency</B> function.
  44. If the <B>pthread_setconcurrency</B> function was not previously
  45. called, this function shall return zero to indicate that the
  46. implementation is maintaining the concurrency level.
  47. </P>
  48. <P>A call to <B>pthread_setconcurrency</B> shall inform the
  49. implementation of its desired concurrency level. The implementation
  50. shall use this as a hint, not a requirement.
  51. </P>
  52. <P>If an implementation does not support multiplexing of user threads
  53. on top of several kernel-scheduled entities, the
  54. <B>pthread_setconcurrency</B> and <B>pthread_getconcurrency</B>
  55. functions are provided for source code compatibility but they shall
  56. have no effect when called. To maintain the function semantics, the
  57. <I>new_level</I> parameter is saved when <B>pthread_setconcurrency</B>
  58. is called so that a subsequent call to <B>pthread_getconcurrency</B>
  59. shall return the same value.
  60. </P>
  61. <P><B>Pthreads-w32</B> provides these routines for source code
  62. compatibility only, as described in the previous paragraph.</P>
  63. <H2><A HREF="#toc3" NAME="sect3">Return Value</A></H2>
  64. <P>If successful, the <B>pthread_setconcurrency</B> function shall
  65. return zero; otherwise, an error number shall be returned to indicate
  66. the error.
  67. </P>
  68. <P>The <B>pthread_getconcurrency</B> function shall always return the
  69. concurrency level set by a previous call to <B>pthread_setconcurrency</B>
  70. . If the <B>pthread_setconcurrency</B> function has never been
  71. called, <B>pthread_getconcurrency</B> shall return zero.
  72. </P>
  73. <H2><A HREF="#toc4" NAME="sect4">Errors</A></H2>
  74. <P>The <B>pthread_setconcurrency</B> function shall fail if:
  75. </P>
  76. <DL>
  77. <DT><B>EINVAL</B>
  78. </DT><DD>
  79. The value specified by <I>new_level</I> is negative.
  80. </DD><DT>
  81. <B>EAGAIN</B>
  82. </DT><DD STYLE="margin-bottom: 0.5cm">
  83. The value specific by <I>new_level</I> would cause a system resource
  84. to be exceeded.
  85. </DD></DL>
  86. <P>
  87. These functions shall not return an error code of [EINTR].
  88. </P>
  89. <P><I>The following sections are informative.</I>
  90. </P>
  91. <H2><A HREF="#toc5" NAME="sect5">Examples</A></H2>
  92. <P>None.
  93. </P>
  94. <H2><A HREF="#toc6" NAME="sect6">Application Usage</A></H2>
  95. <P>Use of these functions changes the state of the underlying
  96. concurrency upon which the application depends. Library developers
  97. are advised to not use the <B>pthread_getconcurrency</B> and
  98. <B>pthread_setconcurrency</B> functions since their use may conflict
  99. with an applications use of these functions.
  100. </P>
  101. <H2><A HREF="#toc7" NAME="sect7">Rationale</A></H2>
  102. <P>None.
  103. </P>
  104. <H2><A HREF="#toc8" NAME="sect8">Future Directions</A></H2>
  105. <P>None.
  106. </P>
  107. <H2><A HREF="#toc9" NAME="sect9">See Also</A></H2>
  108. <P>The Base Definitions volume of IEEE&nbsp;Std&nbsp;1003.1-2001,
  109. <I>&lt;pthread.h&gt;</I>
  110. </P>
  111. <H2><A HREF="#toc10" NAME="sect10">Copyright</A></H2>
  112. <P>Portions of this text are reprinted and reproduced in electronic
  113. form from IEEE Std 1003.1, 2003 Edition, Standard for Information
  114. Technology -- Portable Operating System Interface (POSIX), The Open
  115. Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the
  116. Institute of Electrical and Electronics Engineers, Inc and The Open
  117. Group. In the event of any discrepancy between this version and the
  118. original IEEE and The Open Group Standard, the original IEEE and The
  119. Open Group Standard is the referee document. The original Standard
  120. can be obtained online at <A HREF="http://www.opengroup.org/unix/online.html">http://www.opengroup.org/unix/online.html</A>
  121. .
  122. </P>
  123. <P>Modified by Ross Johnson for use with <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A>.</P>
  124. <HR>
  125. <P><A NAME="toc"></A><B>Table of Contents</B></P>
  126. <UL>
  127. <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A>
  128. </P>
  129. <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A>
  130. </P>
  131. <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A>
  132. </P>
  133. <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">Return
  134. Value</A>
  135. </P>
  136. <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect4" NAME="toc4">Errors</A>
  137. </P>
  138. <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect5" NAME="toc5">Examples</A>
  139. </P>
  140. <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect6" NAME="toc6">Application
  141. Usage</A>
  142. </P>
  143. <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect7" NAME="toc7">Rationale</A>
  144. </P>
  145. <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect8" NAME="toc8">Future
  146. Directions</A>
  147. </P>
  148. <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect9" NAME="toc9">See
  149. Also</A>
  150. </P>
  151. <LI><P><A HREF="#sect10" NAME="toc10">Copyright</A>
  152. </P>
  153. </UL>
  154. </BODY>
  155. </HTML>