当前位置: 首页>>代码示例>>C++>>正文


C++ ShbIpcGetShbMemHeader函数代码示例

本文整理汇总了C++中ShbIpcGetShbMemHeader函数的典型用法代码示例。如果您正苦于以下问题:C++ ShbIpcGetShbMemHeader函数的具体用法?C++ ShbIpcGetShbMemHeader怎么用?C++ ShbIpcGetShbMemHeader使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了ShbIpcGetShbMemHeader函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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);
}
开发者ID:cheeryguo,项目名称:BnR_MC,代码行数:40,代码来源:ShbIpc-LinuxPthreads.c

示例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;
}
开发者ID:vinodpa,项目名称:openPOWERLINK_systec,代码行数:45,代码来源:ShbIpc-VxWorks.c

示例3: 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;
}
开发者ID:vinodpa,项目名称:openPOWERLINK_systec,代码行数:44,代码来源:ShbIpc-VxWorks.c

示例4: 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;

}
开发者ID:Lezval,项目名称:openPOWERLINK_systec,代码行数:28,代码来源:ShbIpc-LinuxKernel.c

示例5: 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;
}
开发者ID:Lezval,项目名称:openPOWERLINK_systec,代码行数:34,代码来源:ShbIpc-LinuxKernel.c

示例6: 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);
}
开发者ID:vinodpa,项目名称:openPOWERLINK_systec,代码行数:34,代码来源:ShbIpc-VxWorks.c

示例7: 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;
}
开发者ID:Lezval,项目名称:openPOWERLINK_systec,代码行数:59,代码来源:ShbIpc-LinuxKernel.c

示例8: ShbIpcProcessNewData

static tShbError  ShbIpcProcessNewData (void)
{
tShbMemInst*        pShbMemInst;
tShbMemHeader*      pShbMemHeader;
tShbInstance        pShbInstance = NULL;
int                 fCallAgain;
tSigHndlrNewData    pfnSigHndlrNewData;
tShbPriority        Priority = kShbPriorityLow;
BOOL                fEndOfProcessList = FALSE;
tShbError           ShbError = kShbOk;

    ppShbIpcProcessListNewDataCurrent_g = &pShbIpcProcessListNewDataFirst_g;

    while (fEndOfProcessList == FALSE)
    {
        pfnSigHndlrNewData = NULL;

        pShbMemInst = *ppShbIpcProcessListNewDataCurrent_g;
        if (pShbMemInst == NULL)
        {
            fEndOfProcessList = TRUE;
        }
        else
        {
            pShbMemHeader = ShbIpcGetShbMemHeader (pShbMemInst);

            if (pShbMemHeader->m_fNewData != FALSE)
            {
                pfnSigHndlrNewData = pShbMemInst->m_pfnSigHndlrNewData;
                pShbInstance       = ShbIpcGetInstance(pShbMemInst);
                Priority           = pShbMemInst->m_PriorityNewData;

                pShbMemHeader->m_fNewData = FALSE;
            }

            ppShbIpcProcessListNewDataCurrent_g = &pShbMemInst->m_pProcessListNewDataNext;
        }

        if (pfnSigHndlrNewData != NULL)
        {
            // signal all NewData events if high priority
            // signal just one for lower priorities
            do
            {
                fCallAgain = pfnSigHndlrNewData(pShbInstance);
            }
            while ((fCallAgain != FALSE) && (Priority == kShbPriorityHigh));

            if (fCallAgain != FALSE)
            {
                pShbMemHeader->m_fNewData = TRUE;
            }
        }
    }
    ppShbIpcProcessListNewDataCurrent_g = NULL;

    return ShbError;
}
开发者ID:vinodpa,项目名称:openPOWERLINK_systec,代码行数:58,代码来源:ShbIpc-NoOS.c

示例9: 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);
}
开发者ID:vinodpa,项目名称:openPOWERLINK_systec,代码行数:67,代码来源:ShbIpc-VxWorks.c

示例10: 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;

}
开发者ID:Lezval,项目名称:openPOWERLINK_systec,代码行数:54,代码来源:ShbIpc-LinuxKernel.c

示例11: 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;

}
开发者ID:vinodpa,项目名称:openPOWERLINK_systec,代码行数:53,代码来源:ShbIpc-NoOS.c

示例12: 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;
}
开发者ID:cheeryguo,项目名称:BnR_MC,代码行数:61,代码来源:ShbIpc-LinuxPthreads.c

示例13: 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;

}
开发者ID:vinodpa,项目名称:openPOWERLINK_systec,代码行数:51,代码来源:ShbIpc-NoOS.c

示例14: ShbIpcStartSignalingJobReady

//------------------------------------------------------------------------------
// Function:    ShbIpcStartSignalingJobReady
//
// Description: Start signaling for job ready (called from waiting process)
//
// Parameters:
//      pShbInstance_p                  pointer to shared buffer instance
//      ulTimeOut_p                     job ready timeout
//      pfnSignalHandlerJobReady_p      function pointer to callback function
//
// Return:      tShbError      = error code
//------------------------------------------------------------------------------
tShbError ShbIpcStartSignalingJobReady(tShbInstance pShbInstance_p,
                                       unsigned long ulTimeOut_p,
                                       tSigHndlrJobReady pfnSignalHandlerJobReady_p)
{
    tShbMemInst*    pShbMemInst;
    tShbMemHeader*  pShbMemHeader;
    tShbError       ShbError;
    struct sched_param  schedParam;

    if ((pShbInstance_p == NULL) || (pfnSignalHandlerJobReady_p == NULL))
    {
        return (kShbInvalidArg);
    }

    pShbMemInst   = ShbIpcGetShbMemInst   (pShbInstance_p);
    pShbMemHeader = ShbIpcGetShbMemHeader (pShbInstance_p);
    ShbError = kShbOk;

    if ((pShbMemInst->m_fJobReadyThreadStarted) ||
        (pShbMemInst->m_pfnSigHndlrJobReady != NULL))
    {
        ShbError = kShbAlreadySignaling;
        goto Exit;
    }

    pShbMemInst->m_ulTimeOutMsJobReady = ulTimeOut_p;
    pShbMemInst->m_pfnSigHndlrJobReady = pfnSignalHandlerJobReady_p;

    //create thread for job ready signaling
    if (pthread_create(&pShbMemInst->m_tThreadJobReadyId, NULL,
                   &ShbIpcThreadSignalJobReady, pShbInstance_p) != 0)
    {
        pShbMemInst->m_pfnSigHndlrJobReady = NULL;
        ShbError = kShbInvalidSigHndlr;
        goto Exit;
    }

    schedParam.__sched_priority = EPL_THREAD_PRIORITY_LOW;
    if (pthread_setschedparam(pShbMemInst->m_tThreadNewDataId, SCHED_FIFO,
                              &schedParam) != 0)
    {
        EPL_DBGLVL_ERROR_TRACE2("%s(): couldn't set thread scheduling parameters! %d\n",
               __func__, schedParam.__sched_priority);
    }

Exit:

    return ShbError;
}
开发者ID:cheeryguo,项目名称:BnR_MC,代码行数:61,代码来源:ShbIpc-LinuxPthreads.c

示例15: ShbIpcReleaseBuffer

//------------------------------------------------------------------------------
// Function:    ShbIpcReleaseBuffer
//
// Description: Releases a shared buffer
//
// Parameters:  pShbInstance_p          pointer to shared buffer instance
//
// Return:      tShbError = error code
//------------------------------------------------------------------------------
tShbError  ShbIpcReleaseBuffer (tShbInstance pShbInstance_p)
{
    tShbMemInst*        pShbMemInst;
    tShbMemHeader*      pShbMemHeader;
    tShbError           ShbError;

    if (pShbInstance_p == NULL)
    {
        return (kShbInvalidArg);
    }

    pShbMemInst = ShbIpcGetShbMemInst(pShbInstance_p);
    pShbMemHeader = ShbIpcGetShbMemHeader(pShbInstance_p);

    EPL_DBGLVL_SHB_TRACE("%s() pShbInstance=%p pShbMemHeader=%p\n", __func__,
    		              (void *)pShbInstance_p, (void *)pShbMemHeader);

    // stop threads in any case, because they are bound to that specific instance
    ShbIpcStopSignalingNewData (pShbInstance_p);

    pShbMemHeader->m_ulRefCount--;

    if(pShbMemHeader->m_ulRefCount == 0)
    {
        EPL_DBGLVL_SHB_TRACE("%s() refCount = 0,  destroy shared mem\n",
        		             __func__);
        //delete semaphores
        semDelete(pShbMemHeader->m_mutexBuffAccess);
        semDelete(pShbMemHeader->m_semNewData);
        semDelete(pShbMemHeader->m_semJobReady);
        semDelete(pShbMemHeader->m_semStopSignalingNewData);

        //destroy Buffer
        ShbIpcFree(pShbMemHeader->m_uiBufferKey);

        ShbError = kShbOk;
    }
    else
    {
        EPL_DBGLVL_SHB_TRACE("%s() refCount > 0, detach from shared mem\n",
        		             __func__);
        ShbError = kShbMemUsedByOtherProcs;
    }

    //delete privat mem
    ShbIpcReleasePrivateMem (pShbMemInst);

    return (ShbError);
}
开发者ID:vinodpa,项目名称:openPOWERLINK_systec,代码行数:58,代码来源:ShbIpc-VxWorks.c


注:本文中的ShbIpcGetShbMemHeader函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。