kernel: add k_thread_create() API
Unline k_thread_spawn(), the struct k_thread can live anywhere and not in the thread's stack region. This will be useful for memory protection scenarios where private kernel structures for a thread are not accessible by that thread, or we want to allow the thread to use all the stack space we gave it. This requires a change to the internal _new_thread() API as we need to provide a separate pointer for the k_thread. By default, we still create internal threads with the k_thread in stack memory. Forthcoming patches will change this, but we first need to make it easier to define k_thread memory of variable size depending on whether we need to store coprocessor state or not. Change-Id: I533bbcf317833ba67a771b356b6bbc6596bf60f5 Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
parent
2a0d16593a
commit
d26cf2dc33
16 changed files with 147 additions and 100 deletions
|
@ -142,20 +142,19 @@ extern void _init_thread_base(struct _thread_base *thread_base,
|
|||
int priority, u32_t initial_state,
|
||||
unsigned int options);
|
||||
|
||||
static ALWAYS_INLINE struct k_thread *_new_thread_init(char *pStack,
|
||||
size_t stackSize,
|
||||
int prio,
|
||||
unsigned int options)
|
||||
static ALWAYS_INLINE void _new_thread_init(struct k_thread *thread,
|
||||
char *pStack, size_t stackSize,
|
||||
int prio, unsigned int options)
|
||||
{
|
||||
struct k_thread *thread;
|
||||
#if !defined(CONFIG_INIT_STACKS) && !defined(CONFIG_THREAD_STACK_INFO)
|
||||
ARG_UNUSED(pStack);
|
||||
ARG_UNUSED(stackSize);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_INIT_STACKS
|
||||
memset(pStack, 0xaa, stackSize);
|
||||
#endif
|
||||
|
||||
/* Initialize various struct k_thread members */
|
||||
thread = (struct k_thread *)pStack;
|
||||
|
||||
_init_thread_base(&thread->base, prio, _THREAD_PRESTART, options);
|
||||
|
||||
/* static threads overwrite it afterwards with real value */
|
||||
|
@ -171,8 +170,6 @@ static ALWAYS_INLINE struct k_thread *_new_thread_init(char *pStack,
|
|||
thread->stack_info.start = (u32_t)pStack;
|
||||
thread->stack_info.size = (u32_t)stackSize;
|
||||
#endif /* CONFIG_THREAD_STACK_INFO */
|
||||
|
||||
return thread;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_THREAD_MONITOR)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue