pthread_brrr.h

Go to the documentation of this file.
00001 /* 
00002  * Copyright (C) 2005 Abel Bennett.
00003  *
00004  * This is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Lesser General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2.1 of the License, or (at your option) any later version.
00008  *
00009  * This is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Lesser General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Lesser General Public
00015  * License along with the GNU C Library; if not, write to the Free
00016  * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00017  * 02111-1307 USA.
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     arguments:
00189         (1) pointer to an initialized pthread_brrr_t [input/output]
00190      functionality:
00191         (1) to increment the number of threads to wait for
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

Generated on Tue Apr 24 20:01:36 2007 for libctf by  doxygen 1.5.1