BST_VOID BST_SRV_CHNL_ThreadEntry( BST_VOID *pvArg )
{
    BST_OS_MBX_T      **pstMailBox;
    BST_OS_LOCKCNT_T    tThreadLockCnt;
    BST_EVT_HEAD_STRU  *pstEvent;
    BST_UINT32          ulRtnVal;

    if ( BST_NULL_PTR == pvArg )
    {
        return;
    }
    /*
     * 线程参数初始化,包括邮箱,运行标识
     */
    tThreadLockCnt      = BST_OS_ThreadLock ();
    pstMailBox          = (BST_OS_MBX_T **)pvArg;
   *pstMailBox          = BST_OS_CreateMbx
                        ( BST_OS_GetCurrentThreadId(), BST_L_MBOX_SIZE );
    if ( BST_NULL_PTR == *pstMailBox )
    {
        BST_OS_ThreadUnLock ( tThreadLockCnt );
        return;
    }

    BST_SetThreadInitFlag( BST_CHNL_CTRL_THREAD_FLAG );
    g_lstChnlMng        = BST_NULL_PTR;
    BST_OS_InitSpinLock( &g_HighPriCntSpinLock );
    BST_OS_ThreadUnLock ( tThreadLockCnt );

    /*
     * 进入线程主循环,等待邮件,邮件内容为即将执行的任务
     */
    for(;;)
    {
        ulRtnVal        = BST_OS_RecvMail
                       ( *pstMailBox, (BST_VOID **)&pstEvent, BST_OS_SYS_FOREVER );
        BST_ASSERT_NORM( BST_OS_SYS_TIMEOUT == ulRtnVal );
        BST_SRV_ProcChnlCtrEvent( pstEvent );
        /*这里判断指针不为空再次释放,因此需要传递指针的指针*/
        if( BST_NULL_PTR != pstEvent->pucData )
        {
            BST_DBG_LOG1( "tiger BST_OS_FREE 8,", pstEvent->pucData );
            BST_OS_FREE( pstEvent->pucData );
        }
        BST_OS_FREE( pstEvent );
#if ( BST_VER_TYPE == BST_UT_VER )
        break;
#endif
     }
}
BST_VOID BST_CTaskSchdler::AppThread ( BST_VOID* arg )
{
    BST_CORE_CPTask    *pcTask;
    BST_OS_MBX_T      **pstMailBox;
    BST_OS_LOCKCNT_T    tThreadLockCnt;
    BST_UINT32          ulRtnVal;

    if ( BST_NULL_PTR == arg )
    {
        return;
    }
    /*
     * 线程参数初始化,包括邮箱,运行标识
     */
    tThreadLockCnt      = BST_OS_ThreadLock ();
    pstMailBox          = (BST_OS_MBX_T **)arg;
   *pstMailBox          = BST_OS_CreateMbx
                        ( BST_OS_GetCurrentThreadId (), BST_MAX_APP_NUMBER );
    BST_SetThreadInitFlag ( BST_APP_THREAD_FLAG << g_ucAppInitCnt );
    g_ucAppInitCnt++;
    BST_OS_ThreadUnLock ( tThreadLockCnt );

    /*
     * 进入线程主循环,等待邮件,邮件内容为即将执行的任务
     */
    for(;;)
    {
        ulRtnVal        = BST_OS_RecvMail
                       ( *pstMailBox, (BST_VOID **)&pcTask, BST_OS_SYS_FOREVER );
        BST_ASSERT_NORM( BST_OS_SYS_TIMEOUT == ulRtnVal );
        if ( BST_NULL_PTR == pcTask )
        {
            continue;
        }
        if ( BST_FALSE == ChkTaskExist (pcTask) )
        {
            continue;
        }
        if ( BST_TRUE == pcTask->IsBusy () )
        {
            continue;
        }
        pcTask->PEntry ();
    }
}
BST_VOID BST_SRV_CEvent::RcvThread( BST_VOID *pvArg )
{
    BST_OS_MBX_T                      **pstMailBox;
    BST_EVT_HEAD_STRU                  *pstEvtMsg;
    BST_AS_EVT_STRU                    *pstAsEvt;
    BST_ACOM_EVT_STRU                  *pstAcomEvt;
    BST_TIMER_EVT_STRU                 *pstTimerEvt;
    BST_NET_EVENT_STRU                 *pstNetEvt;
    BST_DSPP_CTrsDlVa                  *pcTrslayer;
    BST_SRV_CAsEvt                     *pcAsMng;
    BST_OS_TIMERID_T                    ulTimerId;
    BST_UINT32                          ulRtnVal;

    BST_ASSERT_NULL( pvArg );
    pstMailBox                          = (BST_OS_MBX_T **)pvArg;
   *pstMailBox                          = BST_OS_CreateMbx( BST_OS_GetCurrentThreadId(), BST_M_MBOX_SIZE );
    BST_ASSERT_NULL( *pstMailBox );
    BST_SetThreadInitFlag( BST_MAIN_THREAD_FLAG );

    for (;;)
    {
        ulRtnVal                        = BST_OS_RecvMail( *pstMailBox, (BST_VOID **)&pstEvtMsg, BST_OS_SYS_FOREVER );

        if( BST_OS_SYS_TIMEOUT == ulRtnVal )
        {
            continue;
        }
        if( BST_NULL_PTR == pstEvtMsg )
        {
            continue;
        }
        BST_DBG_LOG1( "BST_SRV_CEvent::RcvThread pstEvtMsg->enId=%d",
                      pstEvtMsg->enId );
        switch( pstEvtMsg->enId )
        {
        case BST_SRV_ACOM_EVENT:
            pcTrslayer                  = BST_DSPP_CTrsDlVa::GetInstance();
            if ( BST_NULL_PTR == pcTrslayer )
            {
                break;
            }
            pstAcomEvt                  = (BST_ACOM_EVT_STRU *)pstEvtMsg;
            pcTrslayer->RxApi( pstAcomEvt->pucData, (BST_UINT16)pstAcomEvt->ulLength );
            break;

        case BST_SRV_AS_EVENT:
            pcAsMng                     = BST_SRV_CAsEvt::GetInstance();
            if ( BST_NULL_PTR == pcAsMng )
            {
                break;
            }
            pstAsEvt                    = (BST_AS_EVT_STRU *)pstEvtMsg;
            pcAsMng->AsEventRcv( pstAsEvt->enAsEvent, pstAsEvt->ulLength,(BST_VOID *)pstAsEvt->pucData );
            break;

        case BST_SRV_TIMER_EVENT:
            pstTimerEvt                 = (BST_TIMER_EVT_STRU *)pstEvtMsg;
            if( BST_OS_SIZEOF(ulTimerId) != pstTimerEvt->ulLength )
            {
                break;
            }
            BST_OS_MEMCPY( &ulTimerId, pstTimerEvt->pucData, BST_OS_SIZEOF(ulTimerId) );
            BST_OS_TimerDoCallBack( ulTimerId );
            break;

        case BST_SRV_TCPIP_EVENT:
            pstNetEvt                   = (BST_NET_EVENT_STRU *)pstEvtMsg;
            if( BST_OS_SIZEOF(BST_IP_EVENT_STRU) != pstNetEvt->ulLength )
            {
                break;
            }
            BST_IP_CallBackEntry ( ( BST_IP_EVENT_STRU * )pstNetEvt->pucData );
            break;

        default:
            break;
        }

        if( BST_NULL_PTR != pstEvtMsg->pucData )
        {
            BST_OS_FREE( pstEvtMsg->pucData );
        }
        BST_OS_FREE( pstEvtMsg );

#if ( BST_VER_TYPE == BST_UT_VER )
        break;
#endif

    }
}