pthread_barrier_init.html 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  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_BARRIER_DESTROY&quot;(P) manual page</TITLE>
  6. <META NAME="GENERATOR" CONTENT="OpenOffice.org 2.0 (Linux)">
  7. <META NAME="CREATED" CONTENT="20050504;11372800">
  8. <META NAME="CHANGEDBY" CONTENT="Ross Johnson">
  9. <META NAME="CHANGED" CONTENT="20060408;9450100">
  10. <!-- manual page source format generated by PolyglotMan v3.2, -->
  11. <!-- available at http://polyglotman.sourceforge.net/ -->
  12. </HEAD>
  13. <BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR">
  14. <H4>POSIX Threads for Windows – REFERENCE - <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4>
  15. <P><A HREF="index.html">Reference Index</A></P>
  16. <P><A HREF="#toc">Table of Contents</A></P>
  17. <H2><A HREF="#toc0" NAME="sect0">Name</A></H2>
  18. <P>pthread_barrier_destroy, pthread_barrier_init - destroy and
  19. initialize a barrier object (<B>ADVANCED REALTIME THREADS</B>)
  20. </P>
  21. <H2><A HREF="#toc1" NAME="sect1">Synopsis</A></H2>
  22. <P><B>#include &lt;pthread.h&gt; </B>
  23. </P>
  24. <P><B>int pthread_barrier_destroy(pthread_barrier_t *</B><I>barrier</I><B>);
  25. <BR>int pthread_barrier_init(pthread_barrier_t *restrict</B> <I>barrier</I><B>,
  26. const pthread_barrierattr_t *restrict</B> <I>attr</I><B>, unsigned</B>
  27. <I>count</I><B>); </B>
  28. </P>
  29. <H2><A HREF="#toc2" NAME="sect2">Description</A></H2>
  30. <P>The <B>pthread_barrier_destroy</B> function shall destroy the
  31. barrier referenced by <I>barrier</I> and release any resources used
  32. by the barrier. The effect of subsequent use of the barrier is
  33. undefined until the barrier is reinitialized by another call to
  34. <B>pthread_barrier_init</B> . An implementation may use this function
  35. to set <I>barrier</I> to an invalid value. An error code is returned if <B>pthread_barrier_destroy</B> is called when any thread is
  36. blocked on the barrier, or if this function is called with an
  37. uninitialized barrier.
  38. </P>
  39. <P>The <B>pthread_barrier_init</B> function shall allocate any
  40. resources required to use the barrier referenced by <I>barrier</I>
  41. and shall initialize the barrier with attributes referenced by <I>attr</I>.
  42. If <I>attr</I> is NULL, the default barrier attributes shall be used;
  43. the effect is the same as passing the address of a default barrier
  44. attributes object. The results are undefined if <B>pthread_barrier_init</B>
  45. is called when any thread is blocked on the barrier (that is, has not
  46. returned from the <A HREF="pthread_barrier_wait.html"><B>pthread_barrier_wait</B>(3)</A>
  47. call). The results are undefined if a barrier is used without first
  48. being initialized. The results are undefined if <B>pthread_barrier_init</B>
  49. is called specifying an already initialized barrier.
  50. </P>
  51. <P>The <I>count</I> argument specifies the number of threads that
  52. must call <A HREF="pthread_barrier_wait.html"><B>pthread_barrier_wait</B>(3)</A>
  53. before any of them successfully return from the call. The value
  54. specified by <I>count</I> must be greater than zero.
  55. </P>
  56. <P>If the <B>pthread_barrier_init</B> function fails, the barrier
  57. shall not be initialized and the contents of <I>barrier</I> are
  58. undefined.
  59. </P>
  60. <P>Only the object referenced by <I>barrier</I> may be used for
  61. performing synchronization. The result of referring to copies of that
  62. object in calls to <B>pthread_barrier_destroy</B> <B>or</B>
  63. <A HREF="pthread_barrier_wait.html"><B>pthread_barrier_wait</B>(3)</A>
  64. is undefined.</P>
  65. <H2><A HREF="#toc3" NAME="sect3">Return Value</A></H2>
  66. <P>Upon successful completion, these functions shall return zero;
  67. otherwise, an error number shall be returned to indicate the error.
  68. </P>
  69. <H2><A HREF="#toc4" NAME="sect4">Errors</A></H2>
  70. <P>The <B>pthread_barrier_destroy</B> function may fail if:
  71. </P>
  72. <DL>
  73. <DT><B>EBUSY</B>
  74. </DT><DD>
  75. The implementation has detected an attempt to destroy a barrier
  76. while it is in use (for example, while being used in a
  77. <A HREF="pthread_barrier_wait.html"><B>pthread_barrier_wait</B>(3)</A>
  78. call) by another thread.
  79. </DD><DT>
  80. <B>EINVAL</B>
  81. </DT><DD STYLE="margin-bottom: 0.5cm">
  82. The value specified by <I>barrier</I> is invalid.
  83. </DD></DL>
  84. <P>
  85. The <B>pthread_barrier_init</B> function shall fail if:
  86. </P>
  87. <DL>
  88. <DT><B>EAGAIN</B>
  89. </DT><DD>
  90. The system lacks the necessary resources to initialize another
  91. barrier.
  92. </DD><DT>
  93. <B>EINVAL</B>
  94. </DT><DD>
  95. The value specified by <I>count</I> is equal to zero.
  96. </DD><DT>
  97. <B>ENOMEM</B>
  98. </DT><DD STYLE="margin-bottom: 0.5cm">
  99. Insufficient memory exists to initialize the barrier.
  100. </DD></DL>
  101. <P>
  102. The <B>pthread_barrier_init</B> function may fail if:
  103. </P>
  104. <DL>
  105. <DT><B>EBUSY</B>
  106. </DT><DD>
  107. The implementation has detected an attempt to reinitialize a barrier
  108. while it is in use (for example, while being used in a
  109. <A HREF="pthread_barrier_wait.html"><B>pthread_barrier_wait</B>(3)</A>
  110. call) by another thread.
  111. </DD><DT>
  112. <B>EINVAL</B>
  113. </DT><DD STYLE="margin-bottom: 0.5cm">
  114. The value specified by <I>attr</I> is invalid.
  115. </DD></DL>
  116. <P>
  117. These functions shall not return an error code of [EINTR].
  118. </P>
  119. <P><I>The following sections are informative.</I>
  120. </P>
  121. <H2><A HREF="#toc5" NAME="sect5">Examples</A></H2>
  122. <P>None.
  123. </P>
  124. <H2><A HREF="#toc6" NAME="sect6">Application Usage</A></H2>
  125. <P>The <B>pthread_barrier_destroy</B> and <B>pthread_barrier_init</B>
  126. functions are part of the Barriers option and need not be provided on
  127. all implementations.
  128. </P>
  129. <P><B>Pthreads-w32</B> defines <B>_POSIX_BARRIERS</B> to indicate
  130. that these routines are implemented and may be used.</P>
  131. <H2><A HREF="#toc7" NAME="sect7">Rationale</A></H2>
  132. <P>None.
  133. </P>
  134. <H2><A HREF="#toc8" NAME="sect8">Future Directions</A></H2>
  135. <P>None.
  136. </P>
  137. <H2><A HREF="#toc11" NAME="sect11">Known Bugs</A></H2>
  138. <DL>
  139. <DD STYLE="margin-left: 0cm; margin-bottom: 0.5cm">In
  140. <B><SPAN LANG="en-GB"><SPAN LANG="en-GB">pthreads-win32</SPAN></SPAN></B>,
  141. the behaviour of threads which enter <A HREF="pthread_barrier_wait.html"><B>pthread_barrier_wait</B>(3)</A>
  142. while the barrier is being destroyed is undefined.
  143. </DD></DL>
  144. <H2>
  145. <A HREF="#toc9" NAME="sect9">See Also</A></H2>
  146. <P><A HREF="pthread_barrier_wait.html"><B>pthread_barrier_wait</B>(3)</A>
  147. <B>,</B> the Base Definitions volume of IEEE&nbsp;Std&nbsp;1003.1-2001,
  148. <I>&lt;pthread.h&gt;</I>
  149. </P>
  150. <H2><A HREF="#toc10" NAME="sect10">Copyright</A></H2>
  151. <P>Portions of this text are reprinted and reproduced in electronic
  152. form from IEEE Std 1003.1, 2003 Edition, Standard for Information
  153. Technology -- Portable Operating System Interface (POSIX), The Open
  154. Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the
  155. Institute of Electrical and Electronics Engineers, Inc and The Open
  156. Group. In the event of any discrepancy between this version and the
  157. original IEEE and The Open Group Standard, the original IEEE and The
  158. Open Group Standard is the referee document. The original Standard
  159. can be obtained online at <A HREF="http://www.opengroup.org/unix/online.html">http://www.opengroup.org/unix/online.html</A>
  160. .
  161. </P>
  162. <P>Modified by Ross Johnson for use with <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A>.</P>
  163. <HR>
  164. <P><A NAME="toc"></A><B>Table of Contents</B></P>
  165. <UL>
  166. <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A>
  167. </P>
  168. <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A>
  169. </P>
  170. <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A>
  171. </P>
  172. <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">Return
  173. Value</A>
  174. </P>
  175. <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect4" NAME="toc4">Errors</A>
  176. </P>
  177. <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect5" NAME="toc5">Examples</A>
  178. </P>
  179. <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect6" NAME="toc6">Application
  180. Usage</A>
  181. </P>
  182. <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect7" NAME="toc7">Rationale</A>
  183. </P>
  184. <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect8" NAME="toc8">Future
  185. Directions</A>
  186. </P>
  187. <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect11" NAME="toc11">Known
  188. Bugs</A>
  189. </P>
  190. <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect9" NAME="toc9">See
  191. Also</A>
  192. </P>
  193. <LI><P><A HREF="#sect10" NAME="toc10">Copyright</A>
  194. </P>
  195. </UL>
  196. </BODY>
  197. </HTML>