From 867f8ee371cf720f72af234fa7592b558de7c5c7 Mon Sep 17 00:00:00 2001 From: Benjamin Walsh Date: Sun, 22 Jan 2017 11:51:25 -0500 Subject: [PATCH] kernel: move K_ESSENTIAL from thread_state to execution_flags The execution_flags will store the user-facing states of a thread. This also fixes a bug where K_ESSENTIAL was already assigned to execution_flags via the options field of k_thread_spawn()/K_THREAD_DEFINE(). Change-Id: I91ad7a62b5d180e09eead8985ff519809959ecf2 Signed-off-by: Benjamin Walsh --- kernel/include/kernel_structs.h | 12 ++++++------ kernel/init.c | 4 ++-- kernel/thread.c | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/kernel/include/kernel_structs.h b/kernel/include/kernel_structs.h index 085a79700d5..e391af09eb8 100644 --- a/kernel/include/kernel_structs.h +++ b/kernel/include/kernel_structs.h @@ -24,8 +24,8 @@ /* states: common uses low bits, arch-specific use high bits */ -/* system thread that must not abort */ -#define K_ESSENTIAL (1 << 0) +/* Not a real thread */ +#define _THREAD_DUMMY (1 << 0) /* Thread is waiting on an object */ #define _THREAD_PENDING (1 << 1) @@ -39,17 +39,17 @@ /* Thread is suspended */ #define _THREAD_SUSPENDED (1 << 4) -/* Not a real thread */ -#define _THREAD_DUMMY (1 << 5) - /* end - states */ /* execution flags: common uses low bits, arch-specific use high bits */ +/* system thread that must not abort */ +#define K_ESSENTIAL (1 << 0) + #if defined(CONFIG_FP_SHARING) /* thread uses floating point registers */ -#define K_FP_REGS (1 << 0) +#define K_FP_REGS (1 << 1) #endif /* end - execution flags */ diff --git a/kernel/init.c b/kernel/init.c index e4ef955c38c..58f2c899200 100644 --- a/kernel/init.c +++ b/kernel/init.c @@ -216,7 +216,7 @@ static void _main(void *unused1, void *unused2, void *unused3) main(); /* Terminate thread normally since it has no more work to do */ - _main_thread->base.thread_state &= ~K_ESSENTIAL; + _main_thread->base.execution_flags &= ~K_ESSENTIAL; } void __weak main(void) @@ -251,7 +251,7 @@ static void prepare_multithreading(struct k_thread *dummy_thread) _current = dummy_thread; - dummy_thread->base.thread_state = K_ESSENTIAL; + dummy_thread->base.execution_flags = K_ESSENTIAL; #endif /* _kernel.ready_q is all zeroes */ diff --git a/kernel/thread.c b/kernel/thread.c index cc9eb17c835..a40b44902f4 100644 --- a/kernel/thread.c +++ b/kernel/thread.c @@ -77,7 +77,7 @@ int k_is_in_isr(void) */ void _thread_essential_set(void) { - _current->base.thread_state |= K_ESSENTIAL; + _current->base.execution_flags |= K_ESSENTIAL; } /* @@ -87,7 +87,7 @@ void _thread_essential_set(void) */ void _thread_essential_clear(void) { - _current->base.thread_state &= ~K_ESSENTIAL; + _current->base.execution_flags &= ~K_ESSENTIAL; } /* @@ -97,7 +97,7 @@ void _thread_essential_clear(void) */ int _is_thread_essential(void) { - return _current->base.thread_state & K_ESSENTIAL; + return _current->base.execution_flags & K_ESSENTIAL; } void k_busy_wait(uint32_t usec_to_wait)