From f281b74c56bb6e6e02580ede60d13b75246365f5 Mon Sep 17 00:00:00 2001 From: Andrew Boie Date: Tue, 30 Jul 2019 14:02:54 -0700 Subject: [PATCH] userspace: set stack object earlier Populate thread->stack_obj earlier in the thread initialization process such that it is set when z_new_thread() is called. There was nothing specific about its position, or the rest of the code in that CONFIG_USERSPACE block, so just move it all up.. Signed-off-by: Andrew Boie --- kernel/thread.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/kernel/thread.c b/kernel/thread.c index 7b0a1d96097..eb24bb2a1df 100644 --- a/kernel/thread.c +++ b/kernel/thread.c @@ -403,6 +403,14 @@ void z_setup_new_thread(struct k_thread *new_thread, void *p1, void *p2, void *p3, int prio, u32_t options, const char *name) { +#ifdef CONFIG_USERSPACE + z_object_init(new_thread); + z_object_init(stack); + new_thread->stack_obj = stack; + + /* Any given thread has access to itself */ + k_object_access_grant(new_thread, new_thread); +#endif stack_size = adjust_stack_size(stack_size); #ifdef CONFIG_THREAD_USERSPACE_LOCAL_DATA @@ -447,14 +455,6 @@ void z_setup_new_thread(struct k_thread *new_thread, new_thread->name[CONFIG_THREAD_MAX_NAME_LEN - 1] = '\0'; } #endif -#ifdef CONFIG_USERSPACE - z_object_init(new_thread); - z_object_init(stack); - new_thread->stack_obj = stack; - - /* Any given thread has access to itself */ - k_object_access_grant(new_thread, new_thread); -#endif #ifdef CONFIG_SCHED_CPU_MASK new_thread->base.cpu_mask = -1; #endif