ucos+lwip应用心得[社区]
timeouts->next->time -= msecs;
timeout->next = timeouts->next;
timeouts->next = timeout;
} else {
for(t = timeouts->next; t != NULL; t = t->next) {
timeout->time -= t->time;
if (t->next == NULL ||
t->next->time > timeout->time) {
if (t->next != NULL) {
t->next->time -= timeout->time;
}
timeout->next = t->next;
t->next = timeout;
break;
}
}
}
}
函数sys_untimeout从当前任务定时事件链表中删除一个定时事件
void sys_untimeout(sys_timeout_handler h, void *arg)
{
struct sys_timeouts *timeouts;
struct sys_timeout *prev_t, *t;
timeouts = sys_arch_timeouts();//返回当前任务定时事件链表起始指针
if (timeouts->next == NULL)//如果链表为空直接返回
{
return;
}
//查找对应定时事件并从链表中删除.
for (t = timeouts->next, prev_t = NULL; t != NULL; prev_t = t, t = t->next)
{
if ((t->h == h) && (t->arg == arg))
{
/* We have a match */
/* Unlink from previous in list */
if (prev_t == NULL)
timeouts->next = t->next;
&nbs
prev_t->next = t->next;
/* If not the last one, add time of this one back to next */
&nb 《ucos+lwip应用心得[社区](第5页)》
本文链接地址:http://www.oyaya.net/fanwen/view/148424.html
timeout->next = timeouts->next;
timeouts->next = timeout;
} else {
for(t = timeouts->next; t != NULL; t = t->next) {
timeout->time -= t->time;
if (t->next == NULL ||
t->next->time > timeout->time) {
if (t->next != NULL) {
t->next->time -= timeout->time;
}
timeout->next = t->next;
t->next = timeout;
break;
}
}
}
}
函数sys_untimeout从当前任务定时事件链表中删除一个定时事件
void sys_untimeout(sys_timeout_handler h, void *arg)
{
struct sys_timeouts *timeouts;
struct sys_timeout *prev_t, *t;
timeouts = sys_arch_timeouts();//返回当前任务定时事件链表起始指针
if (timeouts->next == NULL)//如果链表为空直接返回
{
return;
}
//查找对应定时事件并从链表中删除.
for (t = timeouts->next, prev_t = NULL; t != NULL; prev_t = t, t = t->next)
{
if ((t->h == h) && (t->arg == arg))
{
/* We have a match */
/* Unlink from previous in list */
if (prev_t == NULL)
timeouts->next = t->next;
&nbs
p;else
prev_t->next = t->next;
/* If not the last one, add time of this one back to next */
&nb 《ucos+lwip应用心得[社区](第5页)》