00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00045 #ifndef _PTHREAD_JAIL_
00046 #define _PTHREAD_JAIL_
00047
00048
00049 #include <pthread.h>
00050 #include <unistd.h>
00051
00052
00053 #ifdef __cplusplus
00054 extern "C" {
00055 #endif
00056
00057
00061 typedef struct
00062 {
00066 pthread_mutexattr_t mutex_attr;
00067
00071 pthread_condattr_t cond_attr;
00072
00076 int pshared;
00077
00078 } pthread_jailattr_t;
00079
00080
00084 typedef struct
00085 {
00089 pthread_mutex_t lock;
00090
00094 pthread_cond_t search_cond;
00095
00099 pthread_cond_t lock_cond;
00100
00104 int visit_count;
00105
00109 int search_count;
00110
00114 int search_wait;
00115
00119 int lock_count;
00120
00124 int lock_wait;
00125
00126 #ifdef CTF_STATS
00127
00130 int total_visitor_count;
00131
00135 int total_wait_count;
00136
00140 int total_lockdown_count;
00141
00145 float total_search_wait;
00146
00150 float total_lockdown_wait;
00151
00155 float total_lockdown;
00156 #endif
00157
00158 } pthread_jail_t;
00159
00160
00164 #ifdef CTF_STATS
00165 #define PTHREAD_JAIL_INITIALIZER { PTHREAD_MUTEX_INITIALIZER, \
00166 PTHREAD_COND_INITIALIZER, PTHREAD_COND_INITIALIZER, \
00167 0, 0, 0, 0, 0, \
00168 0, 0, 0, 0.0, 0.0, 0.0 }
00169 #else
00170 #define PTHREAD_JAIL_INITIALIZER { PTHREAD_MUTEX_INITIALIZER, \
00171 PTHREAD_COND_INITIALIZER, PTHREAD_COND_INITIALIZER, \
00172 0, 0, 0, 0, 0 }
00173 #endif
00174
00175
00184 extern int pthread_jail_init(pthread_jail_t * jail,
00185 const pthread_jailattr_t * attr);
00186
00194 extern int pthread_jail_destroy(pthread_jail_t * jail);
00195
00203 extern int pthread_jail_search(pthread_jail_t * jail);
00204
00212 extern int pthread_jail_visit(pthread_jail_t * jail);
00213
00221 extern int pthread_jail_leave(pthread_jail_t * jail);
00222
00230 extern int pthread_jail_lockdown(pthread_jail_t * jail);
00231
00239 extern int pthread_jail_release(pthread_jail_t * jail);
00240
00248 extern int pthread_jailattr_init(pthread_jailattr_t * attr);
00249
00257 extern int pthread_jailattr_destroy(pthread_jailattr_t * attr);
00258
00259 #if (_POSIX_THREAD_PROCESS_SHARED == 1)
00260
00268 extern int pthread_jailattr_getpshared(const pthread_jailattr_t * attr,
00269 int * pshared);
00270
00279 extern int pthread_jailattr_setpshared(pthread_jailattr_t * attr,
00280 const int pshared);
00281 #endif
00282
00283
00284 #ifdef __cplusplus
00285 }
00286 #endif
00287
00288 #endif