Merge pull request #3335 from geniusgogo/fixed_timerlist_search
[src/timer.c]fixed rt_timer_list_next_timeout multi-task safe
This commit is contained in:
commit
f390d79f1b
19
src/timer.c
19
src/timer.c
|
@ -108,14 +108,23 @@ static void _rt_timer_init(rt_timer_t timer,
|
|||
static rt_tick_t rt_timer_list_next_timeout(rt_list_t timer_list[])
|
||||
{
|
||||
struct rt_timer *timer;
|
||||
register rt_base_t level;
|
||||
rt_tick_t timeout_tick = RT_TICK_MAX;
|
||||
|
||||
if (rt_list_isempty(&timer_list[RT_TIMER_SKIP_LIST_LEVEL - 1]))
|
||||
return RT_TICK_MAX;
|
||||
/* disable interrupt */
|
||||
level = rt_hw_interrupt_disable();
|
||||
|
||||
timer = rt_list_entry(timer_list[RT_TIMER_SKIP_LIST_LEVEL - 1].next,
|
||||
struct rt_timer, row[RT_TIMER_SKIP_LIST_LEVEL - 1]);
|
||||
if (!rt_list_isempty(&timer_list[RT_TIMER_SKIP_LIST_LEVEL - 1]))
|
||||
{
|
||||
timer = rt_list_entry(timer_list[RT_TIMER_SKIP_LIST_LEVEL - 1].next,
|
||||
struct rt_timer, row[RT_TIMER_SKIP_LIST_LEVEL - 1]);
|
||||
timeout_tick = timer->timeout_tick;
|
||||
}
|
||||
|
||||
return timer->timeout_tick;
|
||||
/* enable interrupt */
|
||||
rt_hw_interrupt_enable(level);
|
||||
|
||||
return timeout_tick;
|
||||
}
|
||||
|
||||
rt_inline void _rt_timer_remove(rt_timer_t timer)
|
||||
|
|
Loading…
Reference in New Issue