diff --git a/arch/sim/Kconfig b/arch/sim/Kconfig index 74fbba8574..37cf394b9a 100644 --- a/arch/sim/Kconfig +++ b/arch/sim/Kconfig @@ -134,6 +134,13 @@ config SIM_WALLTIME_SIGNAL endchoice +config SIM_STACKSIZE_ADJUSTMENT + int "The adjustment of stack size for sim" + default 65536 + ---help--- + The adjustment of stack size for sim. When the task is created, + the stack size is increased by this amount. + config SIM_HOSTFS bool "Simulated HostFS" depends on FS_HOSTFS diff --git a/arch/sim/src/sim/up_createstack.c b/arch/sim/src/sim/up_createstack.c index bc14d30531..666c21fe25 100644 --- a/arch/sim/src/sim/up_createstack.c +++ b/arch/sim/src/sim/up_createstack.c @@ -92,6 +92,8 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) FAR uint8_t *stack_alloc_ptr; int ret = ERROR; + stack_size += CONFIG_SIM_STACKSIZE_ADJUSTMENT; + #ifdef CONFIG_TLS_ALIGNED /* The allocated stack size must not exceed the maximum possible for the * TLS feature. diff --git a/arch/sim/src/sim/up_initialstate.c b/arch/sim/src/sim/up_initialstate.c index eba0bd14d7..fe719d385a 100644 --- a/arch/sim/src/sim/up_initialstate.c +++ b/arch/sim/src/sim/up_initialstate.c @@ -57,9 +57,11 @@ void up_initial_state(struct tcb_s *tcb) if (tcb->pid == 0) { tcb->stack_alloc_ptr = (void *)(up_getsp() - - CONFIG_IDLETHREAD_STACKSIZE); + CONFIG_IDLETHREAD_STACKSIZE - + CONFIG_SIM_STACKSIZE_ADJUSTMENT); tcb->stack_base_ptr = tcb->stack_alloc_ptr; - tcb->adj_stack_size = CONFIG_IDLETHREAD_STACKSIZE; + tcb->adj_stack_size = CONFIG_IDLETHREAD_STACKSIZE + + CONFIG_SIM_STACKSIZE_ADJUSTMENT; #ifdef CONFIG_STACK_COLORATION /* If stack debug is enabled, then fill the stack with a diff --git a/sched/Kconfig b/sched/Kconfig index 05b13117d7..29761acae1 100644 --- a/sched/Kconfig +++ b/sched/Kconfig @@ -1808,14 +1808,12 @@ menu "Stack and heap information" config DEFAULT_TASK_STACKSIZE int "The default stack size for tasks" - default 65536 if ARCH_SIM default 2048 ---help--- The default stack size for tasks. 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