From dfed8c4874b4e87d809c8bf64a8f8adc8048915f Mon Sep 17 00:00:00 2001 From: Vincenzo Frascino Date: Mon, 27 Mar 2017 15:52:42 +0100 Subject: [PATCH] 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 --- kernel/Kconfig | 8 ++++++++ kernel/include/kernel_structs.h | 20 ++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/kernel/Kconfig b/kernel/Kconfig index d0c16a622b3..03e586bbc46 100644 --- a/kernel/Kconfig +++ b/kernel/Kconfig @@ -138,6 +138,14 @@ config ISR_STACK_SIZE This option specifies the size of the stack used by interrupt 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 bool prompt "Thread custom data" diff --git a/kernel/include/kernel_structs.h b/kernel/include/kernel_structs.h index 02bfc4526be..6263b8d612f 100644 --- a/kernel/include/kernel_structs.h +++ b/kernel/include/kernel_structs.h @@ -65,6 +65,16 @@ struct __thread_entry { }; #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 */ struct _thread_base { @@ -148,6 +158,11 @@ struct k_thread { int errno_var; #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 */ struct _thread_arch arch; }; @@ -265,6 +280,11 @@ static ALWAYS_INLINE struct k_thread *_new_thread_init(char *pStack, thread->custom_data = NULL; #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; }