Within the <env>OSFactory class declaration, you must define a set of virtual operations that creates the operating system services needed by the application. These services include tasking, synchronization, connection ports, message queues, and timing services.
In the VxOS.h file, the declaration of virtual operations is as follows:
public:
virtual OMOSMessageQueue *createOMOSMessageQueue(
OMBoolean /* shouldGrow */ = TRUE,
const long messageQueueSize =
OMOSThread::DefaultMessageQueueSize)
{ return (OMOSMessageQueue*)new
VxOSMessageQueue(messageQueueSize);}
virtual OMOSConnectionPort *createOMOSConnectionPort()
{
#ifdef _OMINSTRUMENT
return (OMOSConnectionPort*)new VxConnectionPort();
#else
return NULL;
#endif
}
virtual OMOSEventFlag* createOMOSEventFlag() {
return (OMOSEventFlag *)new VxOSEventFlag(); }
virtual OMOSThread *createOMOSThread(void tfunc(
void*), void *param,
const char* const threadName = NULL,
const long stackSize=OMOSThread::DefaultStackSize)
{return (OMOSThread*)new VxThread(tfunc, param,
threadName, stackSize);};
virtual OMOSThread* createOMOSWrapperThread(
void* osHandle) {
if (NULL == osHandle)
osHandle = getCurrentThreadHandle();
return (OMOSThread*)new VxThread(osHandle);
}
virtual OMOSMutex *createOMOSMutex() {return
(OMOSMutex*)new VxMutex();}
virtual OMOSTimer *createOMOSTickTimer(timeUnit tim,
void cbkfunc(void*), void *param) {
return (OMOSTimer*)new VxTimer(tim, cbkfunc,
param); // TickTimer for real time
}
virtual OMOSTimer *createOMOSIdleTimer(
void cbkfunc(void*), void *param) {
return (OMOSTimer*)new VxTimer(cbkfunc, param);
/ Idle timer for simulated time
}
virtual OMOSSemaphore* createOMOSSemaphore(
unsigned long semFlags = 0,
unsigned long initialCount = 1,
unsigned long /* maxCount */ = 1,
const char * const /* name */ = NULL)
{
return (OMOSSemaphore*) new VxSemaphore(
semFlags, initialCount);
}
virtual void* getCurrentThreadHandle();
virtual void delayCurrentThread(timeUnit ms);
virtual OMBoolean waitOnThread(void* osHandle,
timeUnit ms) {return FALSE;
}
};