|
@@ -25,6 +25,7 @@
|
|
* 2013-12-21 Grissiom let rt_thread_idle_excute loop until there is no
|
|
* 2013-12-21 Grissiom let rt_thread_idle_excute loop until there is no
|
|
* dead thread.
|
|
* dead thread.
|
|
* 2016-08-09 ArdaFu add method to get the handler of the idle 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>
|
|
#include <rthw.h>
|
|
@@ -123,6 +124,10 @@ void rt_thread_idle_excute(void)
|
|
#endif
|
|
#endif
|
|
/* remove defunct thread */
|
|
/* remove defunct thread */
|
|
rt_list_remove(&(thread->tlist));
|
|
rt_list_remove(&(thread->tlist));
|
|
|
|
+
|
|
|
|
+ /* lock scheduler to prevent scheduling in cleanup function. */
|
|
|
|
+ rt_enter_critical();
|
|
|
|
+
|
|
/* invoke thread cleanup */
|
|
/* invoke thread cleanup */
|
|
if (thread->cleanup != RT_NULL)
|
|
if (thread->cleanup != RT_NULL)
|
|
thread->cleanup(thread);
|
|
thread->cleanup(thread);
|
|
@@ -134,11 +139,17 @@ void rt_thread_idle_excute(void)
|
|
/* if it's a system object, not delete it */
|
|
/* if it's a system object, not delete it */
|
|
if (rt_object_is_systemobject((rt_object_t)thread) == RT_TRUE)
|
|
if (rt_object_is_systemobject((rt_object_t)thread) == RT_TRUE)
|
|
{
|
|
{
|
|
|
|
+ /* unlock scheduler */
|
|
|
|
+ rt_exit_critical();
|
|
|
|
+
|
|
/* enable interrupt */
|
|
/* enable interrupt */
|
|
rt_hw_interrupt_enable(lock);
|
|
rt_hw_interrupt_enable(lock);
|
|
|
|
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /* unlock scheduler */
|
|
|
|
+ rt_exit_critical();
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|