kernel: Refactor common _new_thread init code
We do a bit of the same stuff on all the arch's to setup a new thread. So lets put that code in a common place so we unify it for everyone and reduce some duplicated code. Change-Id: Ic04121bfd6846aece16aa7ffd4382bdcdb6136e3 Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This commit is contained in:
parent
5742a508a2
commit
b8823c4efd
7 changed files with 44 additions and 95 deletions
|
@ -12,6 +12,7 @@
|
|||
#if !defined(_ASMLANGUAGE)
|
||||
#include <atomic.h>
|
||||
#include <misc/dlist.h>
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
@ -239,6 +240,34 @@ 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)
|
||||
{
|
||||
struct k_thread *thread;
|
||||
|
||||
#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 */
|
||||
thread->init_data = NULL;
|
||||
thread->fn_abort = NULL;
|
||||
|
||||
#ifdef CONFIG_THREAD_CUSTOM_DATA
|
||||
/* Initialize custom data field (value is opaque to kernel) */
|
||||
thread->custom_data = NULL;
|
||||
#endif
|
||||
|
||||
return thread;
|
||||
}
|
||||
|
||||
#endif /* _ASMLANGUAGE */
|
||||
|
||||
#endif /* _kernel_structs__h_ */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue