00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00037 #ifndef _PTHREAD_BRRR_
00038 #define _PTHREAD_BRRR_
00039
00040
00041 #include <pthread.h>
00042 #include <unistd.h>
00043
00044
00045 #ifdef __cplusplus
00046 extern "C" {
00047 #endif
00048
00049
00053 #define PTHREAD_BRRR_SERIAL_THREAD -1
00054
00058 typedef struct
00059 {
00063 pthread_mutexattr_t mutex_attr;
00064
00068 pthread_condattr_t cond_attr;
00069
00073 int pshared;
00074
00075 } pthread_brrrattr_t;
00076
00080 typedef struct
00081 {
00085 pthread_mutex_t lock;
00086
00090 pthread_cond_t cond;
00091
00095 int cycle;
00096
00100 int count;
00101
00105 int max_count;
00106
00107 #ifdef CTF_STATS
00108
00111 int total_count;
00112
00116 int total_barriers;
00117
00121 float total_wait;
00122
00123 #endif
00124
00125 } pthread_brrr_t;
00126
00127
00131 #ifdef CTF_STATS
00132 #define PTHREAD_BRRR_INITIALIZER(count) { PTHREAD_MUTEX_INITIALIZER, \
00133 PTHREAD_COND_INITIALIZER, 0, 0, count, \
00134 0, 0, 0.0 }
00135 #else
00136 #define PTHREAD_BRRR_INITIALIZER(count) { PTHREAD_MUTEX_INITIALIZER, \
00137 PTHREAD_COND_INITIALIZER, 0, 0, count }
00138 #endif
00139
00149 extern int pthread_brrr_init(pthread_brrr_t * brrr,
00150 const pthread_brrrattr_t * attr, const int value);
00151
00159 extern int pthread_brrr_destroy(pthread_brrr_t * brrr);
00160
00168 extern int pthread_brrr_wait(pthread_brrr_t * brrr);
00169
00177 extern int pthread_brrr_decrement_np(pthread_brrr_t * brrr);
00178
00186 extern int pthread_brrr_increment_np(pthread_brrr_t * brrr);
00187
00188
00189
00190
00191
00192
00193
00201 extern int pthread_brrrattr_init(pthread_brrrattr_t * attr);
00202
00210 extern int pthread_brrrattr_destroy(pthread_brrrattr_t * attr);
00211
00212 #if (_POSIX_THREAD_PROCESS_SHARED == 1)
00213
00221 extern int pthread_brrrattr_getpshared(const pthread_brrrattr_t * attr,
00222 int * pshared);
00223
00232 extern int pthread_brrrattr_setpshared(pthread_brrrattr_t * attr,
00233 const int pshared);
00234 #endif
00235
00236 #ifdef __cplusplus
00237 }
00238 #endif
00239
00240 #endif