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

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

commit 0a95d64f7094c297cebbf3311e2d5d88215c1970
Author: tengshuangshuang <[email protected]>
AuthorDate: Wed Apr 1 21:45:03 2026 +0800

    ostest/spinlock: Add Kconfig option for test thread priority
    
    The spinlock test threads were created with SCHED_PRIORITY_MAX (255),
    which starves the watchdog feeding task (BSW_TASK_100MS, priority 191)
    on BMP systems with WdgM enabled. The WdgM satellite alive counter
    expires on secondary cores, triggering a WarmReset via SafetyErrMgr
    and powering off the system through semihosting exit.
    Add CONFIG_TESTING_OSTEST_SPINLOCK_PRIORITY Kconfig option (default 255)
    to allow platforms with watchdog monitoring to configure a lower priority.
    Use CONFIG_TESTING_OSTEST_SPINLOCK_PRIORITY in both spinlock_test() and
    run_test_thread() instead of hardcoded priority values.
    
    Assisted-By: mimo-v2.6-pro
    Signed-off-by: tengshuangshuang <[email protected]>
---
 testing/ostest/Kconfig    | 11 +++++++++++
 testing/ostest/spinlock.c |  6 +++---
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/testing/ostest/Kconfig b/testing/ostest/Kconfig
index 635d9fc63..e0e135103 100644
--- a/testing/ostest/Kconfig
+++ b/testing/ostest/Kconfig
@@ -127,6 +127,17 @@ config TESTING_OSTEST_SPINLOCK_THREADS
        default 2
        range 1 32
 
+config TESTING_OSTEST_SPINLOCK_PRIORITY
+       int "Priority of spinlock test threads"
+       default 255
+       range 1 255
+       ---help---
+               Priority for spinlock test threads. Default is 255
+               (SCHED_PRIORITY_MAX). On systems with watchdog monitoring
+               (e.g., BMP with WdgM), using 255 may starve the watchdog
+               feeding task and trigger a system reset. Set this below
+               the watchdog task priority if needed.
+
 config TESTING_OSTEST_MULTIUSER
        bool "Multi-user identity and permission tests"
        default n
diff --git a/testing/ostest/spinlock.c b/testing/ostest/spinlock.c
index e62b5bd28..3a33f5c08 100644
--- a/testing/ostest/spinlock.c
+++ b/testing/ostest/spinlock.c
@@ -254,7 +254,7 @@ void run_test_thread(void *lock, FAR void 
*(*thread_func)(FAR void *arg),
       ASSERT(false);
     }
 
-  sparam.sched_priority = SCHED_PRIORITY_MAX;
+  sparam.sched_priority = CONFIG_TESTING_OSTEST_SPINLOCK_PRIORITY;
   status = pthread_attr_setschedparam(&attr, &sparam);
   if (status != OK)
     {
@@ -433,10 +433,10 @@ void spinlock_test(void)
 
   ASSERT(0 == pthread_attr_init(&attr));
 
-  /* Set the test thread priority to SCHED_PRIORITY_MAX */
+  /* Set the thread priority to CONFIG_TESTING_OSTEST_SPINLOCK_PRIORITY */
 
   ASSERT(0 == sched_getparam(getpid(), &sparam));
-  sparam.sched_priority = SCHED_PRIORITY_MAX;
+  sparam.sched_priority = CONFIG_TESTING_OSTEST_SPINLOCK_PRIORITY;
   ASSERT(0 == pthread_attr_setschedparam(&attr, &sparam));
 
   printf("spinlock_test: start......\n");

Reply via email to