kernel: Add stack_info to k_thread

This patck adds the stack information into the k_thread data structure.
The information will be set by when creating a new thread (_new_thread)
and will be used by the scheduling process.

Change-Id: Ibe79fe92a9ef8bce27bf8616d8e0c878508c267d
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@linaro.org>
This commit is contained in:
Vincenzo Frascino 2017-03-27 15:52:42 +01:00 committed by Kumar Gala
commit dfed8c4874
2 changed files with 28 additions and 0 deletions

View file

@ -138,6 +138,14 @@ config ISR_STACK_SIZE
This option specifies the size of the stack used by interrupt This option specifies the size of the stack used by interrupt
service routines (ISRs), and during kernel initialization. service routines (ISRs), and during kernel initialization.
config THREAD_STACK_INFO
bool
prompt "Thread stack info"
default n
help
This option allows each thread to store the thread stack info into
the k_thread data structure.
config THREAD_CUSTOM_DATA config THREAD_CUSTOM_DATA
bool bool
prompt "Thread custom data" prompt "Thread custom data"

View file

@ -65,6 +65,16 @@ struct __thread_entry {
}; };
#endif #endif
#if defined(CONFIG_THREAD_STACK_INFO)
/* Contains the stack information of a thread */
struct _thread_stack_info {
/* Stack Start */
u32_t start;
/* Stack Size */
u32_t size;
};
#endif /* CONFIG_THREAD_STACK_INFO */
/* can be used for creating 'dummy' threads, e.g. for pending on objects */ /* can be used for creating 'dummy' threads, e.g. for pending on objects */
struct _thread_base { struct _thread_base {
@ -148,6 +158,11 @@ struct k_thread {
int errno_var; int errno_var;
#endif #endif
#if defined(CONFIG_THREAD_STACK_INFO)
/* Stack Info */
struct _thread_stack_info stack_info;
#endif /* CONFIG_THREAD_STACK_INFO */
/* arch-specifics: must always be at the end */ /* arch-specifics: must always be at the end */
struct _thread_arch arch; struct _thread_arch arch;
}; };
@ -265,6 +280,11 @@ static ALWAYS_INLINE struct k_thread *_new_thread_init(char *pStack,
thread->custom_data = NULL; thread->custom_data = NULL;
#endif #endif
#if defined(CONFIG_THREAD_STACK_INFO)
thread->stack_info.start = (u32_t)pStack;
thread->stack_info.size = (u32_t)stackSize;
#endif /* CONFIG_THREAD_STACK_INFO */
return thread; return thread;
} }