nobody wrote on Thursday, June 23, 2005:
1. sometimes , one task want to yield to another task by calling taskYIELD(). But before the task do it, the ISRs maybe have taked place and yield to another in the end of the ISRs. So when control return to that task which will call taskYIELD(), it is unnecessary to yield again.
method to solve it : using context count
// how to use context count
taskENTER_CRITICAL();
… do something else…
xSavedContextCount = xTaskContextCount(); // get the current Context change Count
taskEXIT_CRITICAL();
taskYIELD(xSavedContextCount);
//changed taskYIELD()
taskYIELD(portBASE_TYPE xSavedContextCount)
{
__taskENTER_CRITICAL();
__if (xTaskContextCount() != xSavedContextCount)
__{
____// go on yield
__}
__ taskEXIT_CRITICAL();
}
2.
in vTaskDelayUntil , vTaskDelay
at line 308 in xQueueSend
at line 437 in xQueueReceive ,
there are some code like below
vTaskSuspendAll();
…
if( !xTaskResumeAll() )
{
__taskYIELD();
}
but it’s not completely appropriate to call taskYIELD() when xTaskResumeAll() return pdFALSE because before calling taskYIELD() ISRs maybe also put the current task in the Readylist. So its need not yield again and current task has meet it’s requirement and can go on.
So these code can be
vTaskSuspendAll();
…
xTaskResumeAll() ;
if (current task is not in the readylist)
{
__taskYIELD();
}
these method may be useful.