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 <walsh.benj@gmail.com>
This commit is contained in:
Benjamin Walsh 2017-01-22 11:51:25 -05:00 committed by Anas Nashif
commit 867f8ee371
3 changed files with 11 additions and 11 deletions

View file

@ -24,8 +24,8 @@
/* states: common uses low bits, arch-specific use high bits */ /* states: common uses low bits, arch-specific use high bits */
/* system thread that must not abort */ /* Not a real thread */
#define K_ESSENTIAL (1 << 0) #define _THREAD_DUMMY (1 << 0)
/* Thread is waiting on an object */ /* Thread is waiting on an object */
#define _THREAD_PENDING (1 << 1) #define _THREAD_PENDING (1 << 1)
@ -39,17 +39,17 @@
/* Thread is suspended */ /* Thread is suspended */
#define _THREAD_SUSPENDED (1 << 4) #define _THREAD_SUSPENDED (1 << 4)
/* Not a real thread */
#define _THREAD_DUMMY (1 << 5)
/* end - states */ /* end - states */
/* execution flags: common uses low bits, arch-specific use high bits */ /* 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) #if defined(CONFIG_FP_SHARING)
/* thread uses floating point registers */ /* thread uses floating point registers */
#define K_FP_REGS (1 << 0) #define K_FP_REGS (1 << 1)
#endif #endif
/* end - execution flags */ /* end - execution flags */

View file

@ -216,7 +216,7 @@ static void _main(void *unused1, void *unused2, void *unused3)
main(); main();
/* Terminate thread normally since it has no more work to do */ /* 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) void __weak main(void)
@ -251,7 +251,7 @@ static void prepare_multithreading(struct k_thread *dummy_thread)
_current = dummy_thread; _current = dummy_thread;
dummy_thread->base.thread_state = K_ESSENTIAL; dummy_thread->base.execution_flags = K_ESSENTIAL;
#endif #endif
/* _kernel.ready_q is all zeroes */ /* _kernel.ready_q is all zeroes */

View file

@ -77,7 +77,7 @@ int k_is_in_isr(void)
*/ */
void _thread_essential_set(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) 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) 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) void k_busy_wait(uint32_t usec_to_wait)