static void tcpip_timeouts_mbox_fetch(sys_mbox_t *mbox, void **msg) { u32_t sleeptime, res; again: LWIP_ASSERT_CORE_LOCKED(); sleeptime = sys_timeouts_sleeptime(); if (sleeptime == SYS_TIMEOUTS_SLEEPTIME_INFINITE) { UNLOCK_TCPIP_CORE(); sys_arch_mbox_fetch(mbox, msg, 0); LOCK_...
/** Returned by sys_timeouts_sleeptime() to indicate there is no timer, so we * can sleep forever. */ #define SYS_TIMEOUTS_SLEEPTIME_INFINITE 0xFFFFFFFF 1. 2. 3. 4. 用于指示当前超时定时器链表为空,也就没有超时定时器需要处理 /* Check if timer's expiry time is greater than time and...
if(sleeptime == SYS_TIMEOUTS_SLEEPTIME_INFINITE) {UNLOCK_TCPIP_CORE();sys_arch_mbox_fetch(mbox, msg,0);LOCK_TCPIP_CORE();return; }elseif(sleeptime ==0) {sys_check_timeouts();/* We try again to fetch a message from the mbox. */gotoagain; } 如果没有定时器sleeptime == SYS_TIMEOUT...
static void tcpip_timeouts_mbox_fetch(sys_mbox_t *mbox, void **msg) { u32_t sleeptime, res; again: /* 计算下一个到期的定时器的时间和当前时间的差 */ sleeptime = sys_timeouts_sleeptime(); if (sleeptime == SYS_TIMEOUTS_SLEEPTIME_INFINITE) { /* 系统中没有的定时器 */ UNLOCK_TCPIP_...
TCPIP_MBOX_FETCH即tcpip_timeouts_mbox_fetch会自动调用 sys_check_timeouts。 我们来分析下tcpip_timeouts_mbox_fetch 首先sleeptime = sys_timeouts_sleeptime();获取最近一个将要超时的定时器到现在的时间间隔,这样mbox_fetch时就以该间隔时间作为超时时间sleeptime,这样如果在这个超时时间之前获取到了mbox则处理消息...
通过sys_timeouts_sleeptime()函数获取下次唤醒的时间,到唤醒的时间后就会通过sys_check_timeouts()遍历next_timeout超时链表。这个只是底层的内核超时机制,另外lwip还基于这个机制再实现一套周期定时机制。5.2.2 周期定时机制周期定时机制时基于内核超时机制而实现的。
* timers.h/.c: introduce sys_timeouts_sleeptime (returns the time left before the next timeout is due, for NO_SYS==1) 2015-02-11: Nick van Ijzendoorn * opt.h, sockets.h/c: patch #7702 "Include ability to increase the socket number with defined offset" 2015...
代码清单 9‑6(2):如果sleeptime为SYS_TIMEOUTS_SLEEPTIME_INFINITE,表示当前系统无超时事件,那只需一直等待mbox消息即可,所以调用sys_arch_mbox_fetch()函数进行等待消息,等待时间是一直等待。 代码清单 9‑6(3):如果sleeptime为0表示已经发生超时了,那就调用sys_check_timeouts()去检查一下到底是哪个事件发生超...
static void tcpip_timeouts_mbox_fetch(sys_mbox_t *mbox, void **msg) { u32_t sleeptime, res; again: LWIP_ASSERT_CORE_LOCKED(); ... UNLOCK_TCPIP_CORE(); res = sys_arch_mbox_fetch(mbox, msg, sleeptime); LOCK_TCPIP_CORE(); if (res == SYS_ARCH_TIM...
sys_untimeout(sys_timeout_handler handler, void *arg); +void sys_restart_timeouts(void); #if NO_SYS void sys_check_timeouts(void); -void sys_restart_timeouts(void); u32_t sys_timeouts_sleeptime(void); #else /* NO_SYS */ void sys_timeouts_mbox_fetch(sys_mbox_t *mbox, void **...