提交 55e2fabb 编写于 作者: B Bernard Xiong

[kernel] lock scheduler when cleanup thread

上级 4e41b057
......@@ -25,6 +25,7 @@
* 2013-12-21 Grissiom let rt_thread_idle_excute loop until there is no
* dead thread.
* 2016-08-09 ArdaFu add method to get the handler of the idle thread.
* 2018-02-07 Bernard lock scheduler to protect tid->cleanup.
*/
#include <rthw.h>
......@@ -123,6 +124,10 @@ void rt_thread_idle_excute(void)
#endif
/* remove defunct thread */
rt_list_remove(&(thread->tlist));
/* lock scheduler to prevent scheduling in cleanup function. */
rt_enter_critical();
/* invoke thread cleanup */
if (thread->cleanup != RT_NULL)
thread->cleanup(thread);
......@@ -134,11 +139,17 @@ void rt_thread_idle_excute(void)
/* if it's a system object, not delete it */
if (rt_object_is_systemobject((rt_object_t)thread) == RT_TRUE)
{
/* unlock scheduler */
rt_exit_critical();
/* enable interrupt */
rt_hw_interrupt_enable(lock);
return;
}
/* unlock scheduler */
rt_exit_critical();
}
else
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册