You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2024/06/12 08:10:41 UTC

(nuttx) branch master updated (6f49637e23 -> 56a7bd7972)

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


    from 6f49637e23 Added xmc4_vadc.c to Make.defs
     new caff9eba28 lib/math32.h: add IS_POWER_OF_2 macro
     new 56a7bd7972 sched/kconfig: add PID_INITIAL_COUNT

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 include/nuttx/lib/math32.h | 6 +++++-
 sched/Kconfig              | 9 +++++++++
 sched/init/nx_start.c      | 3 ++-
 3 files changed, 16 insertions(+), 2 deletions(-)


(nuttx) 01/02: lib/math32.h: add IS_POWER_OF_2 macro

Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit caff9eba2899181654d9a2589236b510a19f8ce3
Author: Yanfeng Liu <yf...@qq.com>
AuthorDate: Thu May 30 15:10:06 2024 +0800

    lib/math32.h: add IS_POWER_OF_2 macro
    
    This adds IS_POWER_OF_2 macro to help catching config errors at
    build time.
    
    Signed-off-by: Yanfeng Liu <yf...@qq.com>
    
    Signed-off-by: Yanfeng Liu <yf...@qq.com>
---
 include/nuttx/lib/math32.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/include/nuttx/lib/math32.h b/include/nuttx/lib/math32.h
index 125e8ffab3..cafbd23e56 100644
--- a/include/nuttx/lib/math32.h
+++ b/include/nuttx/lib/math32.h
@@ -52,11 +52,15 @@
 #define FLS2(n)  ((n) & 0x2        ?  1 + FLS1 ((n) >>  1) : FLS1 (n))
 #define FLS1(n)  ((n) & 0x1        ?  1 : 0)
 
+/* Checks if an integer is power of two at compile time */
+
+#define IS_POWER_OF_2(n)           ((n) > 0 && ((n) & (n - 1)) == 0)
+
 /* Returns round up and round down value of log2(n). Note: it can be used at
  * compile time.
  */
 
-#define LOG2_CEIL(n)  ((n) & (n - 1) ? FLS(n) : FLS(n) - 1)
+#define LOG2_CEIL(n)  (IS_POWER_OF_2(n) ? FLS(n) - 1 : FLS(n))
 #define LOG2_FLOOR(n) (FLS(n) - 1)
 
 /****************************************************************************


(nuttx) 02/02: sched/kconfig: add PID_INITIAL_COUNT

Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 56a7bd7972e71956523f1b38aa63f65e8cd44959
Author: Yanfeng Liu <yf...@qq.com>
AuthorDate: Thu May 30 14:36:15 2024 +0800

    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 <yf...@qq.com>
---
 sched/Kconfig         | 9 +++++++++
 sched/init/nx_start.c | 3 ++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/sched/Kconfig b/sched/Kconfig
index 232c009f8c..635cbbb9ba 100644
--- a/sched/Kconfig
+++ b/sched/Kconfig
@@ -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.
diff --git a/sched/init/nx_start.c b/sched/init/nx_start.c
index 1252ff9e6e..852ac5ab72 100644
--- a/sched/init/nx_start.c
+++ b/sched/init/nx_start.c
@@ -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;