提交 f34e9323 编写于 作者: mysterywolf's avatar mysterywolf

对rt_tick_increase临界区进行保护

上级 84fb0923
...@@ -62,6 +62,9 @@ void rt_tick_set(rt_tick_t tick) ...@@ -62,6 +62,9 @@ void rt_tick_set(rt_tick_t tick)
void rt_tick_increase(void) void rt_tick_increase(void)
{ {
struct rt_thread *thread; struct rt_thread *thread;
rt_base_t level;
level = rt_hw_interrupt_disable();
/* increase the global tick */ /* increase the global tick */
#ifdef RT_USING_SMP #ifdef RT_USING_SMP
...@@ -76,17 +79,17 @@ void rt_tick_increase(void) ...@@ -76,17 +79,17 @@ void rt_tick_increase(void)
-- thread->remaining_tick; -- thread->remaining_tick;
if (thread->remaining_tick == 0) if (thread->remaining_tick == 0)
{ {
rt_base_t level;
/* change to initialized tick */ /* change to initialized tick */
thread->remaining_tick = thread->init_tick; thread->remaining_tick = thread->init_tick;
level = rt_hw_interrupt_disable();
thread->stat |= RT_THREAD_STAT_YIELD; thread->stat |= RT_THREAD_STAT_YIELD;
rt_hw_interrupt_enable(level);
rt_hw_interrupt_enable(level);
rt_schedule(); rt_schedule();
} }
else
{
rt_hw_interrupt_enable(level);
}
/* check timer */ /* check timer */
rt_timer_check(); rt_timer_check();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册