spawn: allow zero stacksize/priority to use binary loader defaults

posix_spawnattr_init() no longer pre-fills attr->stacksize and
attr->priority (it leaves them zero, as memset already does).  When a
caller does not set them, the binary loader supplies them from the
loaded ELF (binp->stacksize / binp->priority, parsed from the nx_*
symbols), and nxtask_spawn_exec() falls back to the parent priority and
CONFIG_POSIX_SPAWN_DEFAULT_STACKSIZE for the posix_spawn() function-task
path.

This lets an application's stack size and priority embedded as ELF
symbols actually drive the spawned task, instead of being overridden by
the spawnattr defaults.

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
This commit is contained in:
anjiahao 2026-07-15 17:19:12 +08:00 committed by Alan C. Assis
parent 0178ceab19
commit 745a6e53a4
2 changed files with 29 additions and 8 deletions

View file

@ -75,7 +75,10 @@ int posix_spawnattr_init(posix_spawnattr_t *attr)
return _SCHED_ERRNO(ret);
}
attr->priority = param.sched_priority;
/* attr->priority left at 0: callers that do not set a priority will have
* it filled in from the loaded binary (binp->priority) by the binary
* loader, or from the parent task by task_spawn().
*/
/* Set the default scheduler policy to the policy of this task */
@ -104,13 +107,11 @@ int posix_spawnattr_init(posix_spawnattr_t *attr)
attr->budget.tv_nsec = param.sched_ss_init_budget.tv_nsec;
#endif
/* Default stack size */
attr->stacksize = CONFIG_POSIX_SPAWN_DEFAULT_STACKSIZE;
#ifndef CONFIG_BUILD_KERNEL
attr->stackaddr = NULL;
#endif
/* attr->stacksize and attr->stackaddr left at 0 (memset above): callers
* that do not set a stack size will have it filled in from the loaded
* binary (binp->stacksize) by the binary loader, or from
* CONFIG_POSIX_SPAWN_DEFAULT_STACKSIZE by task_spawn().
*/
return OK;
}