未验证 提交 52d0dc69 编写于 作者: G guo 提交者: GitHub

[kernel]Fixed issue that could all timers stop (#5637)

上级 54219555
......@@ -148,13 +148,15 @@ static void _timer_init(rt_timer_t timer,
*
* @param timer_list is the array of time list
*
* @return the next timer's ticks
* @param timeout_tick is the next timer's ticks
*
* @return Return the operation status. If the return value is RT_EOK, the function is successfully executed.
* If the return value is any other values, it means this operation failed.
*/
static rt_tick_t _timer_list_next_timeout(rt_list_t timer_list[])
static rt_err_t _timer_list_next_timeout(rt_list_t timer_list[], rt_tick_t *timeout_tick)
{
struct rt_timer *timer;
register rt_base_t level;
rt_tick_t timeout_tick = RT_TICK_MAX;
/* disable interrupt */
level = rt_hw_interrupt_disable();
......@@ -163,13 +165,18 @@ static rt_tick_t _timer_list_next_timeout(rt_list_t timer_list[])
{
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;
*timeout_tick = timer->timeout_tick;
/* enable interrupt */
rt_hw_interrupt_enable(level);
return RT_EOK;
}
/* enable interrupt */
rt_hw_interrupt_enable(level);
return timeout_tick;
return -RT_ERROR;
}
/**
......@@ -565,6 +572,7 @@ rt_err_t rt_timer_control(rt_timer_t timer, int cmd, void *arg)
break;
case RT_TIMER_CTRL_SET_TIME:
RT_ASSERT((*(rt_tick_t *)arg) < RT_TICK_MAX / 2);
timer->init_tick = *(rt_tick_t *)arg;
break;
......@@ -682,7 +690,9 @@ void rt_timer_check(void)
*/
rt_tick_t rt_timer_next_timeout_tick(void)
{
return _timer_list_next_timeout(_timer_list);
rt_tick_t next_timeout = RT_TICK_MAX;
_timer_list_next_timeout(_timer_list, &next_timeout);
return next_timeout;
}
#ifdef RT_USING_TIMER_SOFT
......@@ -776,8 +786,7 @@ static void _timer_thread_entry(void *parameter)
while (1)
{
/* get the next timeout tick */
next_timeout = _timer_list_next_timeout(_soft_timer_list);
if (next_timeout == RT_TICK_MAX)
if (_timer_list_next_timeout(_soft_timer_list, &next_timeout) != RT_EOK)
{
/* no software timer exist, suspend self. */
rt_thread_suspend(rt_thread_self());
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册