From 885fcd5147edb878836f17d986e0bb38d5885195 Mon Sep 17 00:00:00 2001 From: Andrew Boie Date: Thu, 5 Oct 2017 14:37:59 -0700 Subject: [PATCH] userspace: de-initialize aborted threads This will allow these thread objects to be re-used. _mark_thread_as_dead() removed, it was only being called in one place. Signed-off-by: Andrew Boie --- kernel/include/ksched.h | 14 -------------- kernel/thread.c | 13 ++++++++++++- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/kernel/include/ksched.h b/kernel/include/ksched.h index 6a30042778e..f17def8d078 100644 --- a/kernel/include/ksched.h +++ b/kernel/include/ksched.h @@ -431,20 +431,6 @@ static inline void _ready_thread(struct k_thread *thread) #endif } -/** - * @brief Mark thread as dead - * - * This routine must be called with interrupts locked. - */ -static inline void _mark_thread_as_dead(struct k_thread *thread) -{ - thread->base.thread_state |= _THREAD_DEAD; - -#ifdef CONFIG_KERNEL_EVENT_LOGGER_THREAD - _sys_k_event_logger_thread_exit(thread); -#endif -} - /* * Set a thread's priority. If the thread is ready, place it in the correct * queue. diff --git a/kernel/thread.c b/kernel/thread.c index a64c31c5674..b0aed233ea0 100644 --- a/kernel/thread.c +++ b/kernel/thread.c @@ -447,7 +447,18 @@ void _k_thread_single_abort(struct k_thread *thread) _abort_thread_timeout(thread); } } - _mark_thread_as_dead(thread); + + thread->base.thread_state |= _THREAD_DEAD; +#ifdef CONFIG_KERNEL_EVENT_LOGGER_THREAD + _sys_k_event_logger_thread_exit(thread); +#endif + +#ifdef CONFIG_USERSPACE + /* Clear initailized state so that this thread object may be re-used + * and triggers errors if API calls are made on it from user threads + */ + _k_object_uninit(thread); +#endif } #ifdef CONFIG_MULTITHREADING