Merge pull request #4738 from enkiller/0528-1028

[kernel] Improve kernel stability
This commit is contained in:
Bernard Xiong 2021-05-28 16:20:56 +08:00 committed by GitHub
commit 06927af8f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View File

@ -124,6 +124,7 @@ rt_inline rt_err_t rt_ipc_list_suspend(rt_list_t *list,
break; break;
default: default:
RT_ASSERT(0);
break; break;
} }

View File

@ -358,6 +358,8 @@ RTM_EXPORT(rt_thread_startup);
*/ */
rt_err_t rt_thread_detach(rt_thread_t thread) rt_err_t rt_thread_detach(rt_thread_t thread)
{ {
rt_base_t lock;
/* thread check */ /* thread check */
RT_ASSERT(thread != RT_NULL); RT_ASSERT(thread != RT_NULL);
RT_ASSERT(rt_object_get_type((rt_object_t)thread) == RT_Object_Class_Thread); RT_ASSERT(rt_object_get_type((rt_object_t)thread) == RT_Object_Class_Thread);
@ -377,12 +379,18 @@ rt_err_t rt_thread_detach(rt_thread_t thread)
/* release thread timer */ /* release thread timer */
rt_timer_detach(&(thread->thread_timer)); rt_timer_detach(&(thread->thread_timer));
/* disable interrupt */
lock = rt_hw_interrupt_disable();
/* change stat */ /* change stat */
thread->stat = RT_THREAD_CLOSE; thread->stat = RT_THREAD_CLOSE;
/* detach thread object */ /* detach thread object */
rt_object_detach((rt_object_t)thread); rt_object_detach((rt_object_t)thread);
/* enable interrupt */
rt_hw_interrupt_enable(lock);
return RT_EOK; return RT_EOK;
} }
RTM_EXPORT(rt_thread_detach); RTM_EXPORT(rt_thread_detach);