先看一下定时事件数据结构
/* 定时回调函数指针 */
typedef void (*sys_timeout_handler)(void *arg);
/* 定时器事件 */
struct sys_timeo
{
struct sys_timeo *next; //下一个定时事件
u32_t time; //定时时间
sys_timeout_handler h; //定时回调函数
void *arg; //定时回调参数
};
所有的定时事件最终被串接在一个链表上
/* 定时事件队列 */
static struct sys_timeo *next_timeout;
下面看一下定时机制的实现代码
/* 初始化定时事件 */
void sys_timeouts_init(void)
{
/* 启动IP重组定时事件 */
sys_timeout(IP_TMR_INTERVAL, ip_reass_timer, NULL);
/* 启动ARP定时事件 */
sys_timeout(ARP_TMR_INTERVAL, arp_timer, NULL);
}
/* 启动定时事件 */
void sys_