mirror of
https://github.com/apache/nuttx.git
synced 2026-08-01 20:28:58 +00:00
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:
parent
0178ceab19
commit
745a6e53a4
2 changed files with 29 additions and 8 deletions
|
|
@ -219,6 +219,26 @@ static int nxtask_spawn_exec(FAR pid_t *pidp, FAR const char *name,
|
|||
stacksize = CONFIG_POSIX_SPAWN_DEFAULT_STACKSIZE;
|
||||
}
|
||||
|
||||
/* A zero priority/stacksize means "use the default": inherit the parent
|
||||
* task's priority and fall back to CONFIG_POSIX_SPAWN_DEFAULT_STACKSIZE.
|
||||
* This lets posix_spawnattr_init() leave these fields zero so that the
|
||||
* binary loader can supply them from the loaded ELF (binp->priority /
|
||||
* binp->stacksize) instead.
|
||||
*/
|
||||
|
||||
if (priority == 0)
|
||||
{
|
||||
struct sched_param param;
|
||||
|
||||
nxsched_get_param(0, ¶m);
|
||||
priority = param.sched_priority;
|
||||
}
|
||||
|
||||
if (stacksize == 0)
|
||||
{
|
||||
stacksize = CONFIG_POSIX_SPAWN_DEFAULT_STACKSIZE;
|
||||
}
|
||||
|
||||
/* Start the task */
|
||||
|
||||
pid = nxtask_spawn_create(name, priority, stackaddr,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue