pthread_mgate.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 
00034 #ifndef _PTHREAD_MGATE_
00035 #define _PTHREAD_MGATE_
00036 
00037 
00038 #include <pthread.h>
00039 #include <unistd.h>
00040 
00041 
00042 #ifdef __cplusplus
00043 extern "C" {
00044 #endif
00045 
00046 
00050 typedef struct
00051 {
00055     pthread_mutexattr_t mutex_attr;
00056 
00060     pthread_condattr_t cond_attr;
00061 
00065     int pshared;
00066 
00067 } pthread_mgateattr_t;
00068 
00069 
00073 struct mgate_data_t
00074 {
00078     int order;
00079 
00083     int gate;
00084 
00088     int wait;
00089 
00093     short token;
00094 
00098     pthread_cond_t cond;
00099 };
00100 
00101 
00105 typedef struct
00106 {
00110     pthread_mutex_t lock;
00111 
00115     struct mgate_data_t * data;
00116 
00120     int num_gates;
00121 
00125     int next_order;
00126 
00127 #ifdef CTF_STATS
00128 
00131     int total_pass_count;
00132 
00136     int total_wait_count;
00137 
00141     float total_wait;
00142 #endif
00143 
00144 } pthread_mgate_t;
00145 
00146 
00156 extern int pthread_mgate_init(pthread_mgate_t * mgate,
00157         const pthread_mgateattr_t * attr, const int num_gates);
00158 
00166 extern int pthread_mgate_destroy(pthread_mgate_t * mgate);
00167 
00177 extern int pthread_mgate_check(pthread_mgate_t * mgate, const int gate_index,
00178         const int check_index);
00179 
00189 extern int pthread_mgate_update(pthread_mgate_t * mgate,
00190         const int gate_index, const int update_index);
00191 
00201 extern int pthread_mgate_pass(pthread_mgate_t * mgate,
00202         const int gate_index, int * order_number);
00203 
00211 extern int pthread_mgate_reset(pthread_mgate_t * mgate);
00212 
00220 extern int pthread_mgateattr_init(pthread_mgateattr_t * attr);
00221 
00229 extern int pthread_mgateattr_destroy(pthread_mgateattr_t * attr);
00230 
00231 #if (_POSIX_THREAD_PROCESS_SHARED == 1)
00232 
00240 extern int pthread_mgateattr_getpshared(const pthread_mgateattr_t * attr,
00241         int * pshared);
00242 
00251 extern int pthread_mgateattr_setpshared(pthread_mgateattr_t * attr,
00252         const int pshared);
00253 #endif
00254 
00255 #ifdef __cplusplus
00256 }
00257 #endif
00258 
00259 #endif

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