kernel/arch: optimize memory use of some thread fields
Some thread fields were 32-bit wide, when they are not even close to using that full range of values. They are instead changed to 8-bit fields. - prio can fit in one byte, limiting the priorities range to -128 to 127 - recursive scheduler locking can be limited to 255; a rollover results most probably from a logic error - flags are split into execution flags and thread states; 8 bits is enough for each of them currently, with at worst two states and four flags to spare (on x86, on other archs, there are six flags to spare) Doing this saves 8 bytes per stack. It also sets up an incoming enhancement when checking if the current thread is preemptible on interrupt exit. Change-Id: Ieb5321a5b99f99173b0605dd4a193c3bc7ddabf4 Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
This commit is contained in:
parent
7e18ab70f9
commit
f955476559
22 changed files with 116 additions and 83 deletions
|
@ -24,14 +24,17 @@
|
|||
#endif
|
||||
|
||||
/*
|
||||
* Common bitmask definitions for the struct tcs->flags bit field.
|
||||
* bitmask definitions for the execution_flags and state
|
||||
*
|
||||
* Must be before kerneL_arch_data.h because it might need them to be already
|
||||
* defined.
|
||||
*/
|
||||
|
||||
/* thread is defined statically */
|
||||
#define K_STATIC (1 << 0)
|
||||
|
||||
/* states: common uses low bits, arch-specific use high bits */
|
||||
|
||||
/* system thread that must not abort */
|
||||
#define K_ESSENTIAL (1 << 0)
|
||||
|
||||
/* Thread is waiting on an object */
|
||||
#define K_PENDING (1 << 1)
|
||||
|
@ -48,13 +51,20 @@
|
|||
/* Not a real thread */
|
||||
#define K_DUMMY (1 << 5)
|
||||
|
||||
/* system thread that must not abort */
|
||||
#define K_ESSENTIAL (1 << 6)
|
||||
/* end - states */
|
||||
|
||||
|
||||
/* execution flags: common uses low bits, arch-specific use high bits */
|
||||
|
||||
/* thread is defined statically */
|
||||
#define K_STATIC (1 << 0)
|
||||
|
||||
#if defined(CONFIG_FP_SHARING)
|
||||
/* thread uses floating point registers */
|
||||
#define K_FP_REGS (1 << 7)
|
||||
#define K_FP_REGS (1 << 1)
|
||||
#endif
|
||||
/* end - execution flags */
|
||||
|
||||
|
||||
#include <kernel_arch_data.h>
|
||||
|
||||
|
@ -76,13 +86,16 @@ struct _thread_base {
|
|||
sys_dnode_t k_q_node;
|
||||
|
||||
/* execution flags */
|
||||
uint32_t flags;
|
||||
uint8_t execution_flags;
|
||||
|
||||
/* thread priority used to sort linked list */
|
||||
int prio;
|
||||
/* thread state */
|
||||
uint8_t thread_state;
|
||||
|
||||
/* scheduler lock count */
|
||||
volatile uint32_t sched_locked;
|
||||
volatile uint8_t sched_locked;
|
||||
|
||||
/* thread priority used to sort linked list */
|
||||
int8_t prio;
|
||||
|
||||
/* data returned by APIs */
|
||||
void *swap_data;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue