/* To take a semaphore */
PAL_Result PAL_osSemTake(PAL_OsSemHandle hSem, Int32 mSecTimeout)
{
PAL_Result semTakeResult = PAL_SOK;
Bool semPendResult;
if( NULL != hSem )
{
/* Only allow semTake, if it is not called from main */
if (TSK_self() != (TSK_Handle)&KNL_dummy) 1
{
#ifdef PAL_OSSEM_ENABLE_STATIC_MEM
semPendResult = SEM_pend(&((PAL_OsSemObj *) hSem)->biosSemObj, mSecTimeout); 2
#else
semPendResult = SEM_pend(hSem, mSecTimeout);
#endif
if ( semPendResult == FALSE )
{
semTakeResult = PSP_E_RESOURCES;
}
else
{
semTakeResult = PAL_SOK;
}
}
}
else
{
semTakeResult = PSP_E_INVAL_PARAM;
}
return semTakeResult;
}
上面是pal_osSem.c库函数,我的代码在走到return semTakeResult之后,又重新回到1处,接着往下执行到return semTakeResult,然后又回到1,大约反复三次后,程序估计走到2就飞了,请问什么原因啊?
|