static portTASK_FUNCTION( prvIdleTask, pvParameters )
{
/* Stop warnings. */
( void ) pvParameters;
/** THIS IS THE RTOS IDLE TASK - WHICH IS CREATED AUTOMATICALLY WHEN THE
SCHEDULER IS STARTED. **/
for( ;; )
{
/* See if any tasks have deleted themselves - if so then the idle task
is responsible for freeing the deleted task's TCB and stack. */
主要作用是清除已被删除的任务的申请的空间。
//这里删除的任务必须是动态分配的才会被删除。静态的不会被删除
prvCheckTasksWaitingTermination();
#if ( ( configUSE_PREEMPTION == 1 ) && ( configIDLE_SHOULD_YIELD == 1 ) )
{
/* When using preemption tasks of equal priority will be
timesliced. If a task that is sharing the idle priority is ready
to run then the idle task should yield before the end of the
timeslice.
A critical region is not required here as we are just reading from
the list, and an occasional incorrect value will not matter. If
the ready list at the idle priority contains more than one task
then a task other than the idle task is ready to execute. */
if( listCURRENT_LIST_LENGTH( &( pxReadyTasksLists[ tskIDLE_PRIORITY ] ) ) > ( UBaseType_t ) 1 )
{
taskYIELD();空闲任务仅执行一会,从这里进行任务调度。解析一
}
else
{
mtCOVERAGE_TEST_MARKER();
}
}
解析一:
taskYIELD();=portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT;
宏展开:
->( * ( ( volatile uint32_t * ) 0xe000ed04 ) )=(1UL << 28UL )
在M3编程手册中,0xe000ed04是寄存器
触发PENDSV中断。
}