Skip to content

Commit

Permalink
kernel: Restore CONFIG_MULTITHREADING=n behavior
Browse files Browse the repository at this point in the history
The prepare_multithreading()/switch_to_main_thread() steps were being
done unconditionally, when with multhreading disabled we want to jump
straight into the main thread on the existing stack.

Needless to say, that doesn't work well.  Fixes zephyrproject-rtos#8361.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
  • Loading branch information
Andy Ross authored and nashif committed Jun 13, 2018
1 parent b20aff2 commit 3d14615
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions kernel/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ static void init_idle_thread(struct k_thread *thr, k_thread_stack_t *stack)
*
* @return N/A
*/
#ifdef CONFIG_MULTITHREADING
static void prepare_multithreading(struct k_thread *dummy_thread)
{
#ifdef CONFIG_ARCH_HAS_CUSTOM_SWAP_TO_MAIN
Expand Down Expand Up @@ -377,6 +378,7 @@ static void switch_to_main_thread(void)
_Swap(irq_lock());
#endif
}
#endif /* CONFIG_MULTITHREDING */

u32_t z_early_boot_rand32_get(void)
{
Expand Down Expand Up @@ -434,6 +436,7 @@ extern uintptr_t __stack_chk_guard;
*/
FUNC_NORETURN void _Cstart(void)
{
#ifdef CONFIG_MULTITHREADING
#ifdef CONFIG_ARCH_HAS_CUSTOM_SWAP_TO_MAIN
struct k_thread *dummy_thread = NULL;
#else
Expand All @@ -444,6 +447,7 @@ FUNC_NORETURN void _Cstart(void)
struct k_thread *dummy_thread = (struct k_thread *)&dummy_thread_memory;

memset(dummy_thread_memory, 0, sizeof(dummy_thread_memory));
#endif
#endif
/*
* The interrupt library needs to be initialized early since a series
Expand All @@ -466,11 +470,15 @@ FUNC_NORETURN void _Cstart(void)
__stack_chk_guard = z_early_boot_rand32_get();
#endif

#ifdef CONFIG_MULTITHREADING
prepare_multithreading(dummy_thread);

/* display boot banner */

switch_to_main_thread();
#else
bg_thread_main(NULL, NULL, NULL);

while (1) {
}
#endif

/*
* Compiler can't tell that the above routines won't return and issues
Expand Down

0 comments on commit 3d14615

Please sign in to comment.