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 5062c58bd3eb20fbb4d10d8c7b50ce3570b8f96d Author: chenzihan1 <[email protected]> AuthorDate: Mon May 19 16:50:47 2025 +0800 system/uorb: Raise the default priority of the uORB tools. uorb_listener and uorb_unit_test run at priority 100 by default, so on a loaded system they are preempted by the publishers they observe. In the latency test of uorb_unit_test, the subscriber thread inherits the priority of the test task and is not scheduled as soon as the main thread publishes, so the measured latency includes the scheduling delay. Raise the default of UORB_PRIORITY to 250 and create the latency test subscriber thread at CONFIG_UORB_PRIORITY + 1, so that it runs as soon as a sample is published. Signed-off-by: chenzihan1 <[email protected]> --- system/uorb/Kconfig | 2 +- system/uorb/test/unit_test.c | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/system/uorb/Kconfig b/system/uorb/Kconfig index 993211a04..56a7cae33 100644 --- a/system/uorb/Kconfig +++ b/system/uorb/Kconfig @@ -12,7 +12,7 @@ if UORB config UORB_PRIORITY int "task priority" - default 100 + default 250 config UORB_STACKSIZE int "stack size" diff --git a/system/uorb/test/unit_test.c b/system/uorb/test/unit_test.c index e4c232b8f..897140618 100644 --- a/system/uorb/test/unit_test.c +++ b/system/uorb/test/unit_test.c @@ -194,6 +194,8 @@ static FAR void *pubsubtest_thread_entry(FAR void *arg) static int latency_test(bool print) { struct orb_test_medium_s sample; + struct sched_param param; + pthread_attr_t attr; pthread_t pubsub_task; int instance = 0; int ret = ERROR; @@ -214,7 +216,11 @@ static int latency_test(bool print) g_pubsubtest_print = print; g_pubsubtest_passed = false; - if (pthread_create(&pubsub_task, NULL, pubsubtest_thread_entry, NULL) < 0) + pthread_attr_init(&attr); + param.sched_priority = CONFIG_UORB_PRIORITY + 1; + pthread_attr_setschedparam(&attr, ¶m); + + if (pthread_create(&pubsub_task, &attr, pubsubtest_thread_entry, NULL) < 0) { test_fail("failed launching latency test task"); goto out;
