framexmit/fxmittask.h

00001 #ifndef _FXMIT_TASK_H
00002 #define _FXMIT_TASK_H
00003 /*----------------------------------------------------------------------*/
00004 /*                                                                      */
00005 /* Module Name: fxmittask.h                                             */
00006 /*                                                                      */
00007 /* Module Description: task and sempahore routines                      */
00008 /* Used to fix include file discrepancies between UNIX and VxWorks      */
00009 /*                                                                      */
00010 /* Module Arguments: none                                               */
00011 /*                                                                      */
00012 /* Revision History:                                                    */
00013 /* Rel   Date     Programmer    Comments                                */
00014 /* 1.0   9Jul98  D. Sigg        First release                           */
00015 /*                                                                      */
00016 /* Documentation References:                                            */
00017 /*      Man Pages: fxmittask.html                                       */
00018 /*      References: none                                                */
00019 /*                                                                      */
00020 /* Author Information:                                                  */
00021 /* Name          Telephone       Fax             e-mail                 */
00022 /* Daniel Sigg   (509) 372-8336  (509) 372-2178  sigg_d@ligo.mit.edu    */
00023 /*                                                                      */
00024 /* Code Compilation and Runtime Specifications:                         */
00025 /*      Code Compiled on: Ultra-Enterprise, Solaris 5.6                 */
00026 /*      Compiler Used: sun workshop C 4.2                               */
00027 /*      Runtime environment: sparc/solaris                              */
00028 /*                                                                      */
00029 /* Code Standards Conformance:                                          */
00030 /*      Code Conforms to: LIGO standards.       OK                      */
00031 /*                        Lint.                 TBD                     */
00032 /*                        ANSI                  OK                      */
00033 /*                        POSIX                 OK (for UNIX)           */
00034 /*                                                                      */
00035 /* Known Bugs, Limitations, Caveats:                                    */
00036 /*                                                                      */
00037 /*                                                                      */
00038 /*                                                                      */
00039 /*                      -------------------                             */
00040 /*                                                                      */
00041 /*                             LIGO                                     */
00042 /*                                                                      */
00043 /*        THE LASER INTERFEROMETER GRAVITATIONAL WAVE OBSERVATORY.      */
00044 /*                                                                      */
00045 /*                     (C) The LIGO Project, 1996.                      */
00046 /*                                                                      */
00047 /*                                                                      */
00048 /* California Institute of Technology                                   */
00049 /* LIGO Project MS 51-33                                                */
00050 /* Pasadena CA 91125                                                    */
00051 /*                                                                      */
00052 /* Massachusetts Institute of Technology                                */
00053 /* LIGO Project MS 20B-145                                              */
00054 /* Cambridge MA 01239                                                   */
00055 /*                                                                      */
00056 /* LIGO Hanford Observatory                                             */
00057 /* P.O. Box 1970 S9-02                                                  */
00058 /* Richland WA 99352                                                    */
00059 /*                                                                      */
00060 /* LIGO Livingston Observatory                                          */
00061 /* 19100 LIGO Lane Rd.                                                  */
00062 /* Livingston, LA 70754                                                 */
00063 /*                                                                      */
00064 /*----------------------------------------------------------------------*/
00065 #ifdef __cplusplus
00066 extern "C" {
00067 #endif
00068 
00069 #ifdef OS_VXWORKS
00070 #include <semLib.h>
00071 #include <taskLib.h>
00072 
00073 #else
00074 #include <pthread.h>
00075 #endif
00076 
00089 
00098 
00110 
00111 #ifndef OS_VXWORKS
00112 
00118    typedef pthread_t taskID_t;
00119 #else
00120    typedef int       taskID_t;
00121 #endif
00122 
00123 
00124 #ifndef OS_VXWORKS
00125 
00131    typedef pthread_mutex_t      mutexID_t;
00132 #else
00133    typedef SEM_ID               mutexID_t;
00134 #endif
00135 
00136 
00137 #ifndef OS_VXWORKS
00138 
00144    typedef void*        taskretarg_t;
00145 #else
00146    typedef void         taskretarg_t;
00147 #endif
00148 
00149 
00156    typedef void* taskarg_t;
00157 
00158 
00164    typedef taskretarg_t (*taskfunc_t) (taskarg_t);
00165 
00166 
00178 
00179 #ifndef OS_VXWORKS
00180 
00188 #define MUTEX_CREATE(sem) \
00189         pthread_mutex_init (&(sem), NULL)
00190 #else
00191 #define MUTEX_CREATE(sem) \
00192         (((sem = semMCreate (SEM_Q_PRIORITY | SEM_INVERSION_SAFE | \
00193                            SEM_DELETE_SAFE)) == NULL) ? 1 : 0)
00194 #endif
00195 
00196 
00197 #ifndef OS_VXWORKS
00198 
00206 #define MUTEX_GET(sem) \
00207         pthread_mutex_lock (&(sem))
00208 #else
00209 #define MUTEX_GET(sem) \
00210         semTake (sem, WAIT_FOREVER)
00211 #endif
00212 
00213 
00214 #ifndef OS_VXWORKS
00215 
00223 #define MUTEX_TRY(sem) \
00224         pthread_mutex_trylock (&(sem))
00225 #else
00226 #define MUTEX_TRY(sem) \
00227         semTake (sem, NO_WAIT)
00228 #endif
00229 
00230 
00231 #ifndef OS_VXWORKS
00232 
00240 #define MUTEX_RELEASE(sem) \
00241         pthread_mutex_unlock (&(sem))
00242 #else
00243 #define MUTEX_RELEASE(sem) \
00244         semGive (sem)
00245 #endif
00246 
00247 
00248 #ifndef OS_VXWORKS
00249 
00257 #define MUTEX_DESTROY(sem) \
00258         pthread_mutex_destroy (&(sem))
00259 #else
00260 #define MUTEX_DESTROY(sem) \
00261         semDelete (sem)
00262 #endif
00263 
00275 
00276 
00295    int taskCreate (int attr, int priority, taskID_t* taskID, 
00296                   const char* taskname, taskfunc_t task, taskarg_t arg);
00297 
00307    int taskCancel (taskID_t* taskID);
00308 
00312 
00313 
00314 #ifdef __cplusplus
00315 }
00316 #endif
00317 
00318 #endif /* _FXMIT_TASK_H */

Generated on Sun Mar 8 19:20:47 2009 for dmt by  doxygen 1.5.4