一、源码
#define RT_TIMER_SKIP_LIST_LEVEL 1
struct rt_list_node
{
struct rt_list_node *next; /**< point to next node. */
struct rt_list_node *prev; /**< point to prev node. */
};
typedef struct rt_list_node rt_list_t; /**< Type for lists. */
/* hard timer list */
static rt_list_t rt_timer_list[RT_TIMER_SKIP_LIST_LEVEL];
/**
* @ingroup SystemInit
*
* This function will initialize system timer
*/
void rt_system_timer_init(void)
{
int i;
for (i = 0; i < sizeof(rt_timer_list) / sizeof(rt_timer_list[0]); i++)
{
rt_list_init(rt_timer_list + i);
}
}
因为RT_TIMER_SKIP_LIST_LEVEL
为1,所以rt_timer_list
只有一个元素。因此sizeof(rt_timer_list) / sizeof(rt_timer_list[0])
等于1。
1、rt_list_init
rt_inline void rt_list_init(rt_list_t *l)
{
l->next = l->prev = l;
}
2、总结
rt_system_timer_init
函数作用为初始化rt_timer_list
数组。