pthread_praq.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 
00035 #ifndef _PTHREAD_PRAQ_H_
00036 #define _PTHREAD_PRAQ_H_
00037 
00038 
00039 #include <pthread.h>
00040 #include <unistd.h>
00041 
00042 
00043 #ifdef __cplusplus
00044 extern "C" {
00045 #endif
00046 
00047 
00051 enum
00052 {
00056     PTHREAD_PRAQ_NONBLOCKING,
00057 
00061     PTHREAD_PRAQ_BLOCKING
00062 
00063 };
00064 
00068 #define PTHREAD_PRAQ_NONBLOCKING PTHREAD_PRAQ_NONBLOCKING
00069 
00073 #define PTHREAD_PRAQ_BLOCKING PTHREAD_PRAQ_BLOCKING
00074 
00078 typedef struct
00079 {
00083     pthread_mutexattr_t mutex_attr;
00084 
00088     pthread_condattr_t cond_attr;
00089 
00093     int pshared;
00094 
00098     int block;
00099 
00100 } pthread_praqattr_t;
00101 
00102 
00106 struct praq_data_t
00107 {
00111     void * data;
00112 
00116     int order_id;
00117 };
00118 
00119 
00123 typedef struct
00124 {
00128     pthread_mutex_t lock;
00129 
00133     pthread_cond_t not_full_cond;
00134 
00138     pthread_cond_t not_empty_cond;
00139 
00143     struct praq_data_t * queue;
00144 
00148     int front;
00149 
00153     int length;
00154 
00158     int max_length;
00159 
00163     int queue_full_wait;
00164 
00168     int queue_empty_wait;
00169 
00173     int order_id;
00174 
00178     int block;
00179 
00180 #ifdef CTF_STATS
00181 
00184     int total_count;
00185 
00189     int total_acquire_wait_count;
00190 
00194     int total_propose_wait_count;
00195 
00199     float total_acquire_wait;
00200 
00204     float total_propose_wait;
00205 #endif
00206 
00207 } pthread_praq_t;
00208 
00209 
00219 extern int pthread_praq_init(pthread_praq_t * praq,
00220         const pthread_praqattr_t * attr, const int length);
00221 
00229 extern int pthread_praq_destroy(pthread_praq_t * praq);
00230 
00239 extern int pthread_praq_acquire(pthread_praq_t * praq,
00240         void ** data);
00241 
00250 extern int pthread_praq_propose(pthread_praq_t * praq, const int order_num);
00251 
00261 extern int pthread_praq_release(pthread_praq_t * praq,
00262         const int order_num, void * data);
00263 
00271 extern int pthread_praq_reset(pthread_praq_t * praq);
00272 
00280 extern int pthread_praqattr_init(pthread_praqattr_t * attr);
00281 
00289 extern int pthread_praqattr_destroy(pthread_praqattr_t * attr);
00290 
00299 extern int pthread_praqattr_getblock(const pthread_praqattr_t * attr,
00300         int * block);
00301 
00310 extern int pthread_praqattr_setblock(pthread_praqattr_t * attr,
00311         const int block);
00312 
00313 #if (_POSIX_THREAD_PROCESS_SHARED == 1)
00314 
00322 extern int pthread_praqattr_getpshared(const pthread_praqattr_t * attr,
00323         int * pshared);
00324 
00333 extern int pthread_praqattr_setpshared(pthread_praqattr_t * attr,
00334         const int pshared);
00335 #endif
00336 
00337 #ifdef __cplusplus
00338 }
00339 #endif
00340 
00341 #endif

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