00001 #ifndef __VXTHREAD_H__
00002 #define __VXTHREAD_H__
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00043
00045 #include <vxWorks.h>
00046 #include <semLib.h>
00047 #include <taskLib.h>
00048
00049
00051
00053 extern "C" void omni_thread_wrapper(void* ptr);
00054
00055
00057
00058
00060 #define OMNI_MUTEX_IMPLEMENTATION \
00061 SEM_ID mutexID; \
00062 bool m_bConstructed;
00063
00064 #define OMNI_CONDITION_IMPLEMENTATION \
00065 long waiters_; \
00066 SEM_ID waiters_lock_; \
00067 SEM_ID sema_;
00068
00069 #define OMNI_SEMAPHORE_IMPLEMENTATION \
00070 SEM_ID semID;
00071
00072 #define OMNI_MUTEX_LOCK_IMPLEMENTATION \
00073 if(semTake(mutexID, WAIT_FOREVER) != OK) \
00074 { \
00075 throw omni_thread_fatal(errno); \
00076 }
00077
00078 #define OMNI_MUTEX_UNLOCK_IMPLEMENTATION \
00079 if(semGive(mutexID) != OK) \
00080 { \
00081 throw omni_thread_fatal(errno); \
00082 }
00083
00084 #define OMNI_THREAD_IMPLEMENTATION \
00085 friend void omni_thread_wrapper(void* ptr); \
00086 static int vxworks_priority(priority_t); \
00087 omni_condition *running_cond; \
00088 void* return_val; \
00089 int tid; \
00090 public: \
00091 static void attach(void); \
00092 static void detach(void); \
00093 static void show(void);
00094
00095
00097
00099
00100
00101
00102
00104 #define main( discarded_argc, discarded_argv ) \
00105 omni_discard_retval() \
00106 { \
00107 throw; \
00108 } \
00109 int omni_main( int argc, char **argv ); \
00110 void launch( ) \
00111 { \
00112 omni_thread* th = new omni_thread( (void(*)(void*))omni_main );\
00113 th->start();\
00114 }\
00115 int omni_main( int argc, char **argv )
00116
00117
00118 #endif // ndef __VXTHREAD_H__