markuskrug wrote on Friday, November 18, 2011:
Hello,
First my Example Application. Both Tasks have the same priority. No other Tasks are existing. The Task vTestTask1 gets started by the scheduler first. ‘a’ is a global variable just to have a dummy job for the tasks.
static portTASK_FUNCTION( vTest1Task, pvParameters )
{
/* The parameters are not used. */
( void ) pvParameters;
for(; {
vTaskSuspend(NULL);
a++;
vTaskResume(xTest2_TaskHandle);
vTaskSuspend(NULL);
}
}
static portTASK_FUNCTION( vTest2Task, pvParameters )
{
/* The parameters are not used. */
( void ) pvParameters;
for(; {
vTaskResume(xTest1_TaskHandle);
vTaskSuspend(NULL);
a++;
}
}
The idea ist that the two tasks suspend themself just after resuming the other. Therefore they should run somhow in a ping-pong matter and increment a. However the application does not behave like this. I discovered that the call of TaskResume(…) does not increase the value of xSuspendedTaskList.uxNumberOfItems. Therefore after the second call of TaskSuspend(NULL) the number of suspended Tasks is 2. Additionally does the value of pxReadyTasksLists.uxNumberOfItems decrease by each call of TaskSuspend, but does not increase by calling TaskResume().
Therefore my application ends in the idle Task very soon.
Can anyone explain my problem ? I read in this forum that there have been some bugs with TaskSuspend in the past. Is this another one ?
Best Regards
Markus