sched/kconfig: add PID_INITIAL_COUNT

This adds config for initial pid limit so that to reduce reallocations
quickly after boot.

Signed-off-by: Yanfeng Liu <yfliu2008@qq.com>
This commit is contained in:
Yanfeng Liu 2024-05-30 14:36:15 +08:00 committed by Xiang Xiao
parent caff9eba28
commit 56a7bd7972
2 changed files with 11 additions and 1 deletions

View File

@ -1939,3 +1939,12 @@ config GROUP_KILL_CHILDREN_TIMEOUT_MS
> 0 means wait timeout
= 0 means don't do kill signal
config PID_INITIAL_COUNT
int "Initial length of pid table"
default 8 if DEFAULT_SMALL
default 16 if !DEFAULT_SMALL
---help---
This is the initial length of pid table, which the system
can still expand when needed. It is rounded up to power of
two by current implementation. If the number of threads in
your system is known at design time, setting this to it.

View File

@ -45,6 +45,7 @@
#include <nuttx/binfmt/binfmt.h>
#include <nuttx/drivers/drivers.h>
#include <nuttx/init.h>
#include <nuttx/lib/math32.h>
#include "task/task.h"
#include "sched/sched.h"
@ -623,7 +624,7 @@ void nx_start(void)
/* Initialize the logic that determine unique process IDs. */
g_npidhash = 4;
g_npidhash = 1 << LOG2_CEIL(CONFIG_PID_INITIAL_COUNT);
while (g_npidhash <= CONFIG_SMP_NCPUS)
{
g_npidhash <<= 1;