本文整理汇总了C++中ShbIpcGetShbMemInst函数的典型用法代码示例。如果您正苦于以下问题:C++ ShbIpcGetShbMemInst函数的具体用法?C++ ShbIpcGetShbMemInst怎么用?C++ ShbIpcGetShbMemInst使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ShbIpcGetShbMemInst函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ShbIpcSignalJobReady
INLINE_FUNCTION tShbError ShbIpcSignalJobReady (
tShbInstance pShbInstance_p)
{
tShbMemInst* pShbMemInst;
HANDLE hEventJobReady;
BOOL fRes;
// TRACE("\nShbIpcSignalJobReady(): enter\n");
if (pShbInstance_p == NULL)
{
return (kShbInvalidArg);
}
pShbMemInst = ShbIpcGetShbMemInst (pShbInstance_p);
ASSERT(pShbMemInst->m_hEventJobReady != INVALID_HANDLE_VALUE);
hEventJobReady = pShbMemInst->m_hEventJobReady;
if (hEventJobReady != INVALID_HANDLE_VALUE)
{
fRes = SetEvent (hEventJobReady);
// TRACE("\nShbIpcSignalJobReady(): EventJobReady set (Result=%d)\n", (int)fRes);
ASSERT( fRes );
}
// TRACE("\nShbIpcSignalJobReady(): leave\n");
return (kShbOk);
}
示例2: ShbIpcThreadSignalNewData
//------------------------------------------------------------------------------
// Function: ShbIpcThreadSignalNewData
//
// Description: Thread for new data signaling
//
// Parameters:
// pvThreadParam_p user parameters for thread
//
// Return: void * thread exit value (not used)
//------------------------------------------------------------------------------
int ShbIpcThreadSignalNewData (int pvThreadParam_p)
{
tShbInstance pShbInstance;
tShbMemInst* pShbMemInst;
tShbMemHeader* pShbMemHeader;
INT iRetVal;
/* thread parameter contains pointer to shared memory */
pShbInstance = (tShbMemInst*)pvThreadParam_p;
pShbMemInst = ShbIpcGetShbMemInst (pShbInstance);
pShbMemHeader = ShbIpcGetShbMemHeader (pShbInstance);
/* signal that thread is running */
pShbMemInst->m_fNewDataThreadStarted = TRUE;
do
{
if ((iRetVal = semTake(pShbMemHeader->m_semNewData,
TIMEOUT_CANCEL_THREAD)) == OK)
{
//check terminate flag
if (!pShbMemInst->m_fThreadTermFlag)
{
pShbMemInst->m_pfnSigHndlrNewData(pShbInstance);
}
}
} while(!pShbMemInst->m_fThreadTermFlag);
//set sem thread terminated
pShbMemInst->m_fNewDataThreadStarted = FALSE;
semGive(pShbMemHeader->m_semStopSignalingNewData);
return 0;
}
示例3: ShbIpcStartSignalingJobReady
INLINE_FUNCTION tShbError ShbIpcStartSignalingJobReady (
tShbInstance pShbInstance_p,
unsigned long ulTimeOutMs_p,
tSigHndlrJobReady pfnSignalHandlerJobReady_p)
{
tShbMemInst* pShbMemInst;
tShbMemHeader* pShbMemHeader;
tShbError ShbError;
if ((pShbInstance_p == NULL) || (pfnSignalHandlerJobReady_p == NULL))
{
return (kShbInvalidArg);
}
pShbMemInst = ShbIpcGetShbMemInst (pShbInstance_p);
pShbMemHeader = ShbIpcGetShbMemHeader (pShbMemInst);
ShbError = kShbOk;
if ((pShbMemInst->m_tThreadJobReadyId != INVALID_ID)
|| (pShbMemInst->m_pfnSigHndlrJobReady != NULL))
{
ShbError = kShbAlreadySignaling;
goto Exit;
}
pShbMemInst->m_ulTimeOutMsJobReady = ulTimeOutMs_p;
pShbMemInst->m_pfnSigHndlrJobReady = pfnSignalHandlerJobReady_p;
pShbMemHeader->m_fJobReady = FALSE;
//create thread for signalling new data
pShbMemInst->m_tThreadJobReadyId = kthread_run(ShbIpcThreadSignalJobReady,
pShbInstance_p,
"ShbJR%p", pShbInstance_p);
Exit:
return ShbError;
}
示例4: ShbIpcLeaveAtomicSection
INLINE_FUNCTION tShbError ShbIpcLeaveAtomicSection (
tShbInstance pShbInstance_p)
{
tShbMemInst* pShbMemInst;
HANDLE hMutexBuffAccess;
BOOL fRes;
tShbError ShbError;
if (pShbInstance_p == NULL)
{
return (kShbInvalidArg);
}
pShbMemInst = ShbIpcGetShbMemInst (pShbInstance_p);
ShbError = kShbOk;
hMutexBuffAccess = pShbMemInst->m_hMutexBuffAccess;
if (hMutexBuffAccess != INVALID_HANDLE_VALUE)
{
fRes = ReleaseMutex (hMutexBuffAccess);
ASSERT( fRes );
}
else
{
ShbError = kShbBufferInvalid;
}
return (ShbError);
}
示例5: ShbIpcEnterAtomicSection
//------------------------------------------------------------------------------
// Function: ShbIpcEnterAtomicSection
//
// Description: Enter atomic section for Shared Buffer access
//
// Parameters: pShbInstance_p pointer to shared buffer instance
//
// Return: tShbError = error code
//------------------------------------------------------------------------------
tShbError ShbIpcEnterAtomicSection (tShbInstance pShbInstance_p)
{
tShbMemInst *pShbMemInst;
tShbMemHeader *pShbMemHeader;
tShbError ShbError;
struct timespec curTime, timeout;
if (pShbInstance_p == NULL)
{
return (kShbInvalidArg);
}
pShbMemInst = ShbIpcGetShbMemInst (pShbInstance_p);
pShbMemHeader = ShbIpcGetShbMemHeader (pShbMemInst);
clock_gettime(CLOCK_REALTIME, &curTime);
timeout.tv_sec = 0;
timeout.tv_nsec = TIMEOUT_ENTER_ATOMIC * 1000;
timespecadd(&timeout, &curTime);
if (pthread_mutex_timedlock(&pShbMemHeader->m_mutexBuffAccess, &timeout) == 0)
{
ShbError = kShbOk;
}
else
{
ShbError = kShbBufferInvalid;
}
return (ShbError);
}
示例6: ShbIpcSignalNewData
//------------------------------------------------------------------------------
// Function: ShbIpcSignalNewData
//
// Description: Signal new data (called from writing process)
//
// Parameters: pShbInstance_p pointer to shared buffer instance
//
// Return: tShbError = error code
//------------------------------------------------------------------------------
tShbError ShbIpcSignalNewData(tShbInstance pShbInstance_p)
{
tShbMemInst* pShbMemInst;
tShbMemHeader* pShbMemHeader;
tShbError ShbError;
//TRACEX("%s() pShbInstance_p=%p\n", __func__, pShbInstance_p);
if (pShbInstance_p == NULL)
{
//TRACEX("%s() Invalid instance!\n", __func__);
return (kShbInvalidArg);
}
pShbMemInst = ShbIpcGetShbMemInst (pShbInstance_p);
pShbMemHeader = ShbIpcGetShbMemHeader (pShbMemInst);
ShbError = kShbOk;
//set semaphore
if (semGive(pShbMemHeader->m_semNewData) < 0)
{
EPL_DBGLVL_ERROR_TRACE("%s() sem_post failed! (%s)\n", __func__,
strerror(errno));
}
/* if this shared buffer is connected to a master buffer, signal the
* data also to the master buffer.
*/
if (pShbMemHeader->m_pShbInstMaster != NULL)
{
return ShbIpcSignalNewData(pShbMemHeader->m_pShbInstMaster);
}
return ShbError;
}
示例7: ShbIpcStopSignalingNewData
INLINE_FUNCTION tShbError ShbIpcStopSignalingNewData (
tShbInstance pShbInstance_p)
{
tShbMemInst* pShbMemInst;
tShbMemHeader* pShbMemHeader;
tShbError ShbError;
DEBUG_LVL_29_TRACE0("------->ShbIpcStopSignalingNewData\n");
if (pShbInstance_p == NULL)
{
return (kShbInvalidArg);
}
ShbError = kShbOk;
pShbMemInst = ShbIpcGetShbMemInst (pShbInstance_p);
pShbMemHeader = ShbIpcGetShbMemHeader (pShbMemInst);
DEBUG_LVL_26_TRACE2("ShbIpcStopSignalingNewData(%p) pfnSignHndlrNewData=%p\n", pShbInstance_p, pShbMemInst->m_pfnSigHndlrNewData);
if (pShbMemInst->m_pfnSigHndlrNewData != NULL)
{ // signal handler was set before
kthread_stop(pShbMemInst->m_tThreadNewDataId);
pShbMemInst->m_pfnSigHndlrNewData = NULL;
pShbMemInst->m_tThreadNewDataId = INVALID_ID;
}
return ShbError;
}
示例8: ShbIpcEnterAtomicSection
//------------------------------------------------------------------------------
// Function: ShbIpcEnterAtomicSection
//
// Description: Enter atomic section for Shared Buffer access
//
// Parameters: pShbInstance_p pointer to shared buffer instance
//
// Return: tShbError = error code
//------------------------------------------------------------------------------
tShbError ShbIpcEnterAtomicSection (tShbInstance pShbInstance_p)
{
tShbMemInst *pShbMemInst;
tShbMemHeader *pShbMemHeader;
tShbError ShbError;
if (pShbInstance_p == NULL)
{
return (kShbInvalidArg);
}
pShbMemInst = ShbIpcGetShbMemInst (pShbInstance_p);
pShbMemHeader = ShbIpcGetShbMemHeader (pShbMemInst);
if (semTake (pShbMemHeader->m_mutexBuffAccess, TIMEOUT_ENTER_ATOMIC) == OK)
{
ShbError = kShbOk;
}
else
{
ShbError = kShbBufferInvalid;
}
return (ShbError);
}
示例9: ShbIpcThreadSignalJobReady
int ShbIpcThreadSignalJobReady (void *pvThreadParam_p)
{
tShbInstance pShbInstance;
tShbMemInst* pShbMemInst;
tShbMemHeader* pShbMemHeader;
long lTimeOutJiffies;
int iRetVal=-1;
pShbInstance = (tShbMemInst*)pvThreadParam_p;
pShbMemInst = ShbIpcGetShbMemInst (pShbInstance);
pShbMemHeader = ShbIpcGetShbMemHeader (pShbMemInst);
DEBUG_LVL_29_TRACE0("ShbIpcThreadSignalJobReady wait for job ready Sem\n");
if (pShbMemInst->m_ulTimeOutMsJobReady != 0)
{
lTimeOutJiffies = (long) pShbMemInst->m_ulTimeOutMsJobReady / (1000 / HZ);
if (lTimeOutJiffies <= 0)
{ // wait at least 1 jiffy
lTimeOutJiffies = 1;
}
//wait for job ready semaphore
iRetVal = wait_event_timeout(pShbMemHeader->m_WaitQueueJobReady,
kthread_should_stop()
|| (pShbMemHeader->m_fJobReady != FALSE),
lTimeOutJiffies);
}
else
{
//wait for job ready semaphore
wait_event_interruptible(pShbMemHeader->m_WaitQueueJobReady,
kthread_should_stop()
|| (pShbMemHeader->m_fJobReady != FALSE));
}
if (pShbMemInst->m_pfnSigHndlrJobReady != NULL)
{
//call Handler
pShbMemInst->m_pfnSigHndlrJobReady(pShbInstance, !pShbMemHeader->m_fJobReady);
}
pShbMemInst->m_pfnSigHndlrJobReady = NULL;
if (down_trylock(&pShbMemInst->m_SemaphoreStopThreadJobReady))
{ // lock failed
wait_event_interruptible(pShbMemHeader->m_WaitQueueJobReady,
kthread_should_stop());
pShbMemInst->m_tThreadJobReadyId = INVALID_ID;
}
else
{
pShbMemInst->m_tThreadJobReadyId = INVALID_ID;
up(&pShbMemInst->m_SemaphoreStopThreadJobReady);
}
DEBUG_LVL_29_TRACE0("ShbIpcThreadSignalJobReady terminated\n");
return 0;
}
示例10: ShbIpcGetShbMemHeader
//------------------------------------------------------------------------------
// Function: ShbIpcGetShbMemHeader
//
// Description: Get pointer to shared memory header
//
// Parameters:
// pShbInstance_p pointer to shared buffer instance
//
// Return: tShbMemHeader* pointer to shared memory header
//------------------------------------------------------------------------------
static inline tShbMemHeader* ShbIpcGetShbMemHeader (tShbInstance pShbInstance_p)
{
tShbMemInst* pShbMemInst;
tShbMemHeader* pShbMemHeader;
pShbMemInst = ShbIpcGetShbMemInst (pShbInstance_p);
pShbMemHeader = pShbMemInst->m_pShbMemHeader;
return (pShbMemHeader);
}
示例11: ShbIpcStartSignalingNewData
//------------------------------------------------------------------------------
// Function: ShbIpcStartSignalingNewData
//
// Description: Start signaling of new data (called from reading process)
//
// Parameters: pShbInstance_p pointer to shared buffer instance
// pfnSignalHandlerNewData_p pointer to master buffer instance
//
// Return: tShbError = error code
//------------------------------------------------------------------------------
tShbError ShbIpcStartSignalingNewData(tShbInstance pShbInstance_p,
tSigHndlrNewData pfnSignalHandlerNewData_p,
tShbPriority ShbPriority_p)
{
tShbMemInst* pShbMemInst;
tShbMemHeader* pShbMemHeader;
tShbError ShbError;
INT iSchedPriority;
if ((pShbInstance_p == NULL) || (pfnSignalHandlerNewData_p == NULL))
{
return (kShbInvalidArg);
}
pShbMemInst = ShbIpcGetShbMemInst (pShbInstance_p);
pShbMemHeader = ShbIpcGetShbMemHeader (pShbInstance_p);
ShbError = kShbOk;
if ((pShbMemInst->m_fNewDataThreadStarted) ||
(pShbMemInst->m_pfnSigHndlrNewData != NULL))
{
ShbError = kShbAlreadySignaling;
EPL_DBGLVL_ERROR_TRACE("%s() Thread already started!\n", __func__);
goto Exit;
}
pShbMemInst->m_pfnSigHndlrNewData = pfnSignalHandlerNewData_p;
iSchedPriority = EPL_TASK_PRIORITY_SHB;
switch (ShbPriority_p)
{
case kShbPriorityLow:
iSchedPriority += 5;
break;
case kShbPriorityNormal:
iSchedPriority += 0;
break;
case kShbPriorityHigh:
iSchedPriority -= 5;
break;
}
if ((pShbMemInst->m_tThreadNewDataId =
taskSpawn ("tShbIpc", iSchedPriority,
0, EPL_TASK_STACK_SIZE, &ShbIpcThreadSignalNewData,
(int)pShbInstance_p, 0, 0, 0, 0, 0, 0, 0, 0, 0)) == ERROR)
{
pShbMemInst->m_pfnSigHndlrNewData = NULL;
ShbError = kShbInvalidSigHndlr;
goto Exit;
}
Exit:
return (ShbError);
}
示例12: ShbIpcStartSignalingNewData
INLINE_FUNCTION tShbError ShbIpcStartSignalingNewData (
tShbInstance pShbInstance_p,
tSigHndlrNewData pfnSignalHandlerNewData_p,
tShbPriority ShbPriority_p)
{
tShbMemInst* pShbMemInst;
tShbMemHeader* pShbMemHeader;
tShbError ShbError;
DEBUG_LVL_29_TRACE0("------->ShbIpcStartSignalingNewData\n");
if ((pShbInstance_p == NULL) || (pfnSignalHandlerNewData_p == NULL))
{
return (kShbInvalidArg);
}
pShbMemInst = ShbIpcGetShbMemInst (pShbInstance_p);
pShbMemHeader = ShbIpcGetShbMemHeader (pShbMemInst);
ShbError = kShbOk;
if ((pShbMemInst->m_tThreadNewDataId != INVALID_ID)
|| (pShbMemInst->m_pfnSigHndlrNewData != NULL))
{
ShbError = kShbAlreadySignaling;
goto Exit;
}
DEBUG_LVL_26_TRACE2("ShbIpcStartSignalingNewData(%p) m_pfnSigHndlrNewData = %p\n", pShbInstance_p, pfnSignalHandlerNewData_p);
pShbMemInst->m_pfnSigHndlrNewData = pfnSignalHandlerNewData_p;
pShbMemHeader->m_fNewData = FALSE;
switch (ShbPriority_p)
{
case kShbPriorityLow:
pShbMemInst->m_lThreadNewDataNice = -2;
break;
case kShbPriorityNormal:
pShbMemInst->m_lThreadNewDataNice = -9;
break;
case kShbPriorityHigh:
pShbMemInst->m_lThreadNewDataNice = -20;
break;
}
//create thread for signalling new data
pShbMemInst->m_tThreadNewDataId = kthread_run(ShbIpcThreadSignalNewData,
pShbInstance_p,
"ShbND%p", pShbInstance_p);
Exit:
return ShbError;
}
示例13: ShbIpcStartSignalingNewData
INLINE_FUNCTION tShbError ShbIpcStartSignalingNewData (
tShbInstance pShbInstance_p,
tSigHndlrNewData pfnSignalHandlerNewData_p,
tShbPriority ShbPriority_p)
{
tShbMemInst* pShbMemInst;
tShbMemInst** ppShbMemInst;
tShbMemHeader* pShbMemHeader;
tShbError ShbError;
DEBUG_LVL_29_TRACE("------->ShbIpcStartSignalingNewData\n");
if (ShbTgtIsInterruptContext())
{
return (kShbInterruptContextNotAllowed);
}
if ((pShbInstance_p == NULL) || (pfnSignalHandlerNewData_p == NULL))
{
return (kShbInvalidArg);
}
pShbMemInst = ShbIpcGetShbMemInst(pShbInstance_p);
pShbMemHeader = ShbIpcGetShbMemHeader(pShbMemInst);
ShbError = kShbOk;
if (pShbMemInst->m_pfnSigHndlrNewData != NULL)
{
ShbError = kShbAlreadySignaling;
goto Exit;
}
DEBUG_LVL_26_TRACE("ShbIpcStartSignalingNewData(%p) m_pfnSigHndlrNewData = %p\n", pShbInstance_p, pfnSignalHandlerNewData_p);
pShbMemInst->m_pfnSigHndlrNewData = pfnSignalHandlerNewData_p;
pShbMemInst->m_PriorityNewData = ShbPriority_p;
pShbMemHeader->m_fNewData = FALSE;
// insert ShbMemInst into NewData process list
// higher priority entries first
ppShbMemInst = &pShbIpcProcessListNewDataFirst_g;
while (*ppShbMemInst != NULL)
{
if ((*ppShbMemInst)->m_PriorityNewData < pShbMemInst->m_PriorityNewData)
{
break;
}
ppShbMemInst = &(*ppShbMemInst)->m_pProcessListNewDataNext;
}
pShbMemInst->m_pProcessListNewDataNext = *ppShbMemInst;
*ppShbMemInst = pShbMemInst;
Exit:
return ShbError;
}
示例14: EPL_DBGLVL_SHB_TRACE2
//------------------------------------------------------------------------------
// Function: ShbIpcThreadSignalJobReady
//
// Description: Thread for new data Job Ready signaling
//
// Parameters:
// pvThreadParam_p user parameters for thread
//
// Return: void * thread exit value (not used)
//------------------------------------------------------------------------------
void *ShbIpcThreadSignalJobReady (void *pvThreadParam_p)
{
tShbInstance pShbInstance;
tShbMemInst *pShbMemInst;
tShbMemHeader* pShbMemHeader;
DWORD ulTimeOut;
INT iRetVal;
UINT fTimeOut;
struct timespec timeout;
EPL_DBGLVL_SHB_TRACE2("%s(): ThreadId:%ld\n", __func__, syscall(SYS_gettid));
pShbInstance = (tShbMemInst*)pvThreadParam_p;
pShbMemInst = ShbIpcGetShbMemInst (pShbInstance);
pShbMemHeader = ShbIpcGetShbMemHeader (pShbInstance);
pShbMemInst->m_fJobReadyThreadStarted = TRUE;
if (pShbMemInst->m_ulTimeOutMsJobReady != 0)
{
ulTimeOut = pShbMemInst->m_ulTimeOutMsJobReady;
clock_gettime(CLOCK_REALTIME, &timeout);
timeout.tv_sec += ulTimeOut;
iRetVal = sem_timedwait(&pShbMemHeader->m_semJobReady, &timeout);
}
else
{
iRetVal = sem_wait(&pShbMemHeader->m_semJobReady);
}
if (iRetVal == 0)
{
fTimeOut = FALSE;
}
else
{
/* timeout or error */
fTimeOut = TRUE;
}
if (pShbMemInst->m_pfnSigHndlrJobReady != NULL)
{
//call Handler
pShbMemInst->m_pfnSigHndlrJobReady(pShbInstance, fTimeOut);
}
pShbMemInst->m_pfnSigHndlrJobReady = NULL;
pShbMemInst->m_fJobReadyThreadStarted = FALSE;
return NULL;
}
示例15: ShbIpcStopSignalingNewData
INLINE_FUNCTION tShbError ShbIpcStopSignalingNewData (
tShbInstance pShbInstance_p)
{
tShbMemInst* pShbMemInst;
tShbMemInst** ppShbMemInst;
tShbMemHeader* pShbMemHeader;
tShbError ShbError;
DEBUG_LVL_29_TRACE("------->ShbIpcStopSignalingNewData\n");
if (ShbTgtIsInterruptContext())
{
return (kShbInterruptContextNotAllowed);
}
if (pShbInstance_p == NULL)
{
return (kShbInvalidArg);
}
ShbError = kShbOk;
pShbMemInst = ShbIpcGetShbMemInst (pShbInstance_p);
pShbMemHeader = ShbIpcGetShbMemHeader (pShbMemInst);
DEBUG_LVL_26_TRACE("ShbIpcStopSignalingNewData(%p) pfnSignHndlrNewData=%p\n", pShbInstance_p, pShbMemInst->m_pfnSigHndlrNewData);
if (pShbMemInst->m_pfnSigHndlrNewData != NULL)
{ // signal handler was set before
// remove pShbMemInst from NewData process list
ShbError = kShbInvalidSigHndlr;
ppShbMemInst = &pShbIpcProcessListNewDataFirst_g;
while (*ppShbMemInst != NULL)
{
if (*ppShbMemInst == pShbMemInst)
{
*ppShbMemInst = pShbMemInst->m_pProcessListNewDataNext;
pShbMemInst->m_pProcessListNewDataNext = NULL;
pShbMemInst->m_pfnSigHndlrNewData = NULL;
if (ppShbIpcProcessListNewDataCurrent_g == &pShbMemInst->m_pProcessListNewDataNext)
{
ppShbIpcProcessListNewDataCurrent_g = ppShbMemInst;
}
ShbError = kShbOk;
break;
}
ppShbMemInst = &(*ppShbMemInst)->m_pProcessListNewDataNext;
}
}
return ShbError;
}