1. FreeRTOS一共9K的代码,分成3部分:
a. 50%: task.c
b. 40%: queue.c
c. 6%: hardware-dependent
Par 1:其中最主要的这9行代码,其他8900多行都是为他服务,保证real time OS始终执行当前最高优先度的task:
#define taskSELECT_HIGHEST_PRIORITY_TASK()
{
/* Find the highest priority queue that contains ready tasks. */
while( listLIST_IS_EMPTY( &( pxReadyTasksLists[ uxTopReadyPriority ] ) ) )
{
configASSERT( uxTopReadyPriority );
--uxTopReadyPriority;
}
/* listGET_OWNER_OF_NEXT_ENTRY indexes through the list, so the tasks of
the same priority get an equal share of the processor time. */
listGET_OWNER_OF_NEXT_ENTRY( pxCurrentTCB, &( pxReadyTasksLists[ uxTopReadyPriority ] ) );
} /* taskSELECT_HIGHEST_PRIORITY_TASK */
Part 2&#x