arch/sim: Initialize the idle thread stack info correctly

and change the default value of IDLETHREAD_STACKSIZE to 65536

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Ia54efbbca4b69706150bc4178844b316688a104e
This commit is contained in:
Xiang Xiao 2021-07-16 02:23:59 +08:00 committed by Masayuki Ishikawa
parent a5ac4463c2
commit cee43ce280
5 changed files with 41 additions and 22 deletions

View File

@ -78,10 +78,5 @@
int up_cpu_idlestack(int cpu, FAR struct tcb_s *tcb, size_t stack_size)
{
/* REVISIT: I don't think anything is needed here */
tcb->adj_stack_size = 0;
tcb->stack_alloc_ptr = NULL;
tcb->stack_base_ptr = NULL;
return OK;
return up_create_stack(tcb, stack_size, TCB_FLAG_TTYPE_KERNEL);
}

View File

@ -165,16 +165,15 @@ void sim_sigdeliver(void);
#ifdef CONFIG_SMP
void sim_cpu0_start(void);
int sim_cpu_start(int cpu, void *stack, size_t size);
void sim_send_ipi(int cpu);
#endif
/* up_smpsignal.c ***********************************************************/
#ifdef CONFIG_SMP
void up_cpu_started(void);
int up_cpu_paused(int cpu);
struct tcb_s *up_this_task(void);
int up_cpu_set_pause_handler(int irq);
void sim_send_ipi(int cpu);
#endif
/* up_oneshot.c *************************************************************/

View File

@ -260,17 +260,12 @@ int up_cpu_index(void)
*
****************************************************************************/
int up_cpu_start(int cpu)
int sim_cpu_start(int cpu, void *stack, size_t size)
{
struct sim_cpuinfo_s cpuinfo;
pthread_attr_t attr;
int ret;
#ifdef CONFIG_SCHED_INSTRUMENTATION
/* Notify of the start event */
sched_note_cpu_start(up_this_task(), cpu);
#endif
/* Initialize the CPU info */
cpuinfo.cpu = cpu;
@ -283,11 +278,13 @@ int up_cpu_start(int cpu)
* in a multi-CPU hardware model.
*/
pthread_attr_init(&attr);
pthread_attr_setstack(&attr, stack, size);
ret = pthread_create(&g_cpu_thread[cpu],
NULL, sim_idle_trampoline, &cpuinfo);
&attr, sim_idle_trampoline, &cpuinfo);
pthread_attr_destroy(&attr);
if (ret != 0)
{
ret = -ret; /* REVISIT: That is a host errno value. */
goto errout_with_cond;
}

View File

@ -233,16 +233,43 @@ void up_cpu_started(void)
}
/****************************************************************************
* Name: up_this_task
* Name: up_cpu_start
*
* Description:
* Return the currrent task tcb.
* In an SMP configution, only one CPU is initially active (CPU 0). System
* initialization occurs on that single thread. At the completion of the
* initialization of the OS, just before beginning normal multitasking,
* the additional CPUs would be started by calling this function.
*
* Each CPU is provided the entry point to is IDLE task when started. A
* TCB for each CPU's IDLE task has been initialized and placed in the
* CPU's g_assignedtasks[cpu] list. A stack has also been allocateded and
* initialized.
*
* The OS initialization logic calls this function repeatedly until each
* CPU has been started, 1 through (CONFIG_SMP_NCPUS-1).
*
* Input Parameters:
* cpu - The index of the CPU being started. This will be a numeric
* value in the range of from one to (CONFIG_SMP_NCPUS-1). (CPU
* 0 is already active)
*
* Returned Value:
* Zero on success; a negated errno value on failure.
*
****************************************************************************/
struct tcb_s *up_this_task(void)
int up_cpu_start(int cpu)
{
return this_task();
FAR struct tcb_s *tcb = current_task(cpu);
#ifdef CONFIG_SCHED_INSTRUMENTATION
/* Notify of the start event */
sched_note_cpu_start(this_task(), cpu);
#endif
return sim_cpu_start(cpu, tcb->stack_base_ptr, tcb->adj_stack_size);
}
/****************************************************************************

View File

@ -1800,6 +1800,7 @@ config DEFAULT_TASK_STACKSIZE
config IDLETHREAD_STACKSIZE
int "Idle thread stack size"
default DEFAULT_TASK_STACKSIZE if ARCH_SIM
default 1024
---help---
The size of the initial stack used by the IDLE thread. The IDLE thread