1pthread_barrier_wait(3C) Standard C Library Functions pthread_barrier_wait(3C)
2
3
4

NAME

6       pthread_barrier_wait - synchronize at a barrier
7

SYNOPSIS

9       cc -mt [ flag... ] file... [ library... ]
10       #include <pthread.h>
11
12       int pthread_barrier_wait(pthread_barrier_t *barrier);
13
14

DESCRIPTION

16       The  pthread_barrier_wait() function synchronizes participating threads
17       at the barrier referenced by barrier. The calling thread  blocks  until
18       the required number of threads have called pthread_barrier_wait() spec‐
19       ifying the barrier.
20
21
22       When the required number of threads have called  pthread_barrier_wait()
23       specifying  the  barrier, the constant PTHREAD_BARRIER_SERIAL_THREAD is
24       returned to one unspecified thread and 0 is returned  to  each  of  the
25       remaining  threads. At this point, the barrier is reset to the state it
26       had as a result of the most  recent  pthread_barrier_init(3C)  function
27       that referenced it.
28
29
30       The  constant  PTHREAD_BARRIER_SERIAL_THREAD  is defined in <pthread.h>
31       and its value is distinct from any other value returned by pthread_bar‐
32       rier_wait().
33
34
35       The results are undefined if this function is called with an uninitial‐
36       ized barrier.
37
38
39       If a signal is delivered to a thread blocked on a barrier, upon  return
40       from  the  signal  handler the thread resumes waiting at the barrier if
41       the barrier wait has not completed (that is, if the required number  of
42       threads  have  not  arrived  at the barrier during the execution of the
43       signal handler); otherwise, the thread continues  as  normal  from  the
44       completed  barrier wait. Until the thread in the signal handler returns
45       from it, it is unspecified whether other threads may proceed  past  the
46       barrier once they have all reached it.
47
48
49       A  thread  that has blocked on a barrier does not prevent any unblocked
50       thread that is eligible to use the same processing resources from even‐
51       tually making forward progress in its execution.
52
53
54       Eligibility  for  processing  resources is determined by the scheduling
55       policy.
56

RETURN VALUES

58       Upon successful completion, the pthread_barrier_wait() function returns
59       PTHREAD_BARRIER_SERIAL_THREAD  for a single (arbitrary) thread synchro‐
60       nized at the barrier and 0 for each of the other threads. Otherwise, an
61       error number is returned to indicate the error.
62

ERRORS

64       The pthread_barrier_wait() function will fail if:
65
66       EINVAL    The  value specified by barrier does not refer to an initial‐
67                 ized barrier object.
68
69

ATTRIBUTES

71       See attributes(5) for descriptions of the following attributes:
72
73
74
75
76       ┌─────────────────────────────┬─────────────────────────────┐
77       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
78       ├─────────────────────────────┼─────────────────────────────┤
79       │Interface Stability          │Standard                     │
80       ├─────────────────────────────┼─────────────────────────────┤
81       │MT-Level                     │MT-Safe                      │
82       └─────────────────────────────┴─────────────────────────────┘
83

SEE ALSO

85       pthread_barrier_destroy(3C), attributes(5), standards(5)
86
87
88
89SunOS 5.11                        30 Jan 2004         pthread_barrier_wait(3C)
Impressum