pthread_barrier.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014 Freie Universität Berlin
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
17 #ifndef PTHREAD_BARRIER_H
18 #define PTHREAD_BARRIER_H
19 
20 #include "mutex.h"
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
32 #define PTHREAD_PROCESS_SHARED (0)
33 
39 #define PTHREAD_PROCESS_PRIVATE (1)
40 
45 {
48  volatile int cont;
50 
57 typedef struct
58 {
61  volatile int count;
63 
69 typedef struct
70 {
71  int pshared;
73 
82  const pthread_barrierattr_t *attr,
83  unsigned int count);
84 
93 
101 
109 
117 
124 int pthread_barrierattr_getpshared(const pthread_barrierattr_t *attr, int *pshared);
125 
134 
135 #ifdef __cplusplus
136 }
137 #endif
138 
139 #endif /* PTHREAD_BARRIER_H */
140 
pthread_barrierattr_t
Details for a pthread_barrier_t.
Definition: pthread_barrier.h:69
kernel_pid_t
int16_t kernel_pid_t
Unique process identifier.
Definition: sched.h:125
pthread_barrier_init
int pthread_barrier_init(pthread_barrier_t *barrier, const pthread_barrierattr_t *attr, unsigned int count)
Initializes a pthread_barrier_t.
pthread_barrierattr_setpshared
int pthread_barrierattr_setpshared(pthread_barrierattr_t *attr, int pshared)
Set if the barrier should be shared with child processes.
pthread_barrier_t::count
volatile int count
Wait for N more threads before waking everyone up.
Definition: pthread_barrier.h:61
pthread_barrier_waiting_node::pid
kernel_pid_t pid
The current thread to wake up.
Definition: pthread_barrier.h:47
pthread_barrier_destroy
int pthread_barrier_destroy(pthread_barrier_t *barrier)
Destroys a pthread_barrier_t.
pthread_barrier_wait
int pthread_barrier_wait(pthread_barrier_t *barrier)
Waiting on a synchronization barrier.
pthread_barrierattr_destroy
int pthread_barrierattr_destroy(pthread_barrierattr_t *attr)
Destroy a pthread_barrierattr_t.
pthread_barrier_waiting_node_t
struct pthread_barrier_waiting_node pthread_barrier_waiting_node_t
Internal structure to store the list of waiting threads.
pthread_barrier_waiting_node::cont
volatile int cont
0 = spurious wake up, 1 = wake up
Definition: pthread_barrier.h:48
pthread_barrier_waiting_node::next
struct pthread_barrier_waiting_node * next
The next waiting thread.
Definition: pthread_barrier.h:46
pthread_barrier_t::mutex
mutex_t mutex
Mutex to unlock to wake the thread up.
Definition: pthread_barrier.h:60
mutex.h
Mutex for thread synchronization.
pthread_barrier_t::next
struct pthread_barrier_waiting_node * next
The first waiting thread.
Definition: pthread_barrier.h:59
pthread_barrier_t
A synchronization barrier.
Definition: pthread_barrier.h:57
pthread_barrierattr_getpshared
int pthread_barrierattr_getpshared(const pthread_barrierattr_t *attr, int *pshared)
Returns whether the barrier attribute was set to be shared.
pthread_barrierattr_t::pshared
int pshared
See pthread_barrierattr_setpshared() and pthread_barrierattr_getpshared().
Definition: pthread_barrier.h:71
pthread_barrierattr_init
int pthread_barrierattr_init(pthread_barrierattr_t *attr)
Initialize a pthread_barrierattr_t.
mutex_t
Mutex structure.
Definition: mutex.h:120
pthread_barrier_waiting_node
Internal structure to store the list of waiting threads.
Definition: pthread_barrier.h:44