From d57583883df5c74fa1929c071c73d9a68ea701ce Mon Sep 17 00:00:00 2001 From: guanyi3 Date: Wed, 14 Jan 2026 23:02:08 +0800 Subject: [PATCH 1/4] apps/ostest: increase testcase priortity to be consistent with ostest ostest may fail because some other task with higher priority are running, this change we use ostest priority for testcases, so that we can easily set testcase priority. Signed-off-by: yangao1 --- testing/ostest/cond.c | 15 +++++++-------- testing/ostest/fpu.c | 2 +- testing/ostest/mqueue.c | 11 +++++------ testing/ostest/nsem.c | 10 +++------- testing/ostest/nxevent.c | 4 ++-- testing/ostest/prioinherit.c | 2 +- testing/ostest/schedlock.c | 2 +- testing/ostest/sem.c | 15 +++++++-------- testing/ostest/semtimed.c | 15 +++++++-------- testing/ostest/sighand.c | 2 +- testing/ostest/signest.c | 2 +- testing/ostest/suspend.c | 2 +- testing/ostest/timedwait.c | 2 +- 13 files changed, 38 insertions(+), 46 deletions(-) diff --git a/testing/ostest/cond.c b/testing/ostest/cond.c index aee88377868..251f40fe82b 100644 --- a/testing/ostest/cond.c +++ b/testing/ostest/cond.c @@ -216,10 +216,10 @@ static void *thread_signaler(void *parameter) #if defined(CONFIG_SMP) && (CONFIG_SMP_NCPUS > 1) /* Workaround for SMP: - * In multi-core environment, thread_signaler would be excecuted prior + * In multi-core environment, thread_signaler would be executed prior * to the thread_waiter, even though priority of thread_signaler is * lower than the thread_waiter. In this case, thread_signaler will - * aquire mutex before the thread_waiter aquires it and will show + * acquire mutex before the thread_waiter acquire it and will show * the error message such as "thread_signaler: ERROR waiter state...". * To avoid this situaltion, we add the following usleep() */ @@ -253,7 +253,6 @@ void cond_test(void) struct sched_param sparam; int prio_min; int prio_max; - int prio_mid; int status; sem_init(&sem_thread_started, 0, 0); @@ -289,11 +288,9 @@ void cond_test(void) printf("cond_test: pthread_attr_init failed, status=%d\n", status); } - prio_min = sched_get_priority_min(SCHED_FIFO); prio_max = sched_get_priority_max(SCHED_FIFO); - prio_mid = (prio_min + prio_max) / 2; - - sparam.sched_priority = prio_mid; + sparam.sched_priority = PRIORITY + 10 <= prio_max ? + PRIORITY + 10 : prio_max; status = pthread_attr_setschedparam(&attr, &sparam); if (status != OK) { @@ -321,7 +318,9 @@ void cond_test(void) printf("cond_test: pthread_attr_init failed, status=%d\n", status); } - sparam.sched_priority = (prio_min + prio_mid) / 2; + prio_min = sched_get_priority_min(SCHED_FIFO); + sparam.sched_priority = PRIORITY - 10 >= prio_min ? + PRIORITY - 10 : prio_min; status = pthread_attr_setschedparam(&attr, &sparam); if (status != OK) { diff --git a/testing/ostest/fpu.c b/testing/ostest/fpu.c index 841d458c7d9..9510158cd0a 100644 --- a/testing/ostest/fpu.c +++ b/testing/ostest/fpu.c @@ -70,7 +70,7 @@ #endif #ifndef CONFIG_TESTING_OSTEST_FPUPRIORITY -# define CONFIG_TESTING_OSTEST_FPUPRIORITY SCHED_PRIORITY_DEFAULT +# define CONFIG_TESTING_OSTEST_FPUPRIORITY PRIORITY #endif #ifndef CONFIG_TESTING_OSTEST_FPUSTACKSIZE diff --git a/testing/ostest/mqueue.c b/testing/ostest/mqueue.c index afd178644f3..33d5463e354 100644 --- a/testing/ostest/mqueue.c +++ b/testing/ostest/mqueue.c @@ -273,7 +273,6 @@ void mqueue_test(void) FAR void *expected; int prio_min; int prio_max; - int prio_mid; int status; /* Reset globals for the beginning of the test */ @@ -301,11 +300,9 @@ void mqueue_test(void) ASSERT(false); } - prio_min = sched_get_priority_min(SCHED_FIFO); prio_max = sched_get_priority_max(SCHED_FIFO); - prio_mid = (prio_min + prio_max) / 2; - - sparam.sched_priority = prio_mid; + sparam.sched_priority = PRIORITY + 10 <= prio_max ? + PRIORITY + 10 : prio_max; status = pthread_attr_setschedparam(&attr, &sparam); if (status != OK) { @@ -348,7 +345,9 @@ void mqueue_test(void) ASSERT(false); } - sparam.sched_priority = (prio_min + prio_mid) / 2; + prio_min = sched_get_priority_min(SCHED_FIFO); + sparam.sched_priority = PRIORITY - 10 >= prio_min ? + PRIORITY - 10 : prio_min; status = pthread_attr_setschedparam(&attr, &sparam); if (status != OK) { diff --git a/testing/ostest/nsem.c b/testing/ostest/nsem.c index a12a162ece4..6e169160a47 100644 --- a/testing/ostest/nsem.c +++ b/testing/ostest/nsem.c @@ -110,10 +110,8 @@ void nsem_test(void) FAR sem_t *sem1; FAR sem_t *sem2; struct sched_param sparam; - int prio_min; - int prio_max; - int prio_mid; pthread_attr_t attr; + int prio_max; int status; /* Open semaphore 2. We will create that one */ @@ -137,11 +135,9 @@ void nsem_test(void) printf("nsem_test: pthread_attr_init failed, status=%d\n", status); } - prio_min = sched_get_priority_min(SCHED_FIFO); prio_max = sched_get_priority_max(SCHED_FIFO); - prio_mid = (prio_min + prio_max) / 2; - - sparam.sched_priority = (prio_mid + prio_max) / 2; + sparam.sched_priority = PRIORITY + 10 <= prio_max ? + PRIORITY + 10 : prio_max; status = pthread_attr_setschedparam(&attr, &sparam); if (status != OK) { diff --git a/testing/ostest/nxevent.c b/testing/ostest/nxevent.c index 6f251c11fb2..af48a76a0eb 100644 --- a/testing/ostest/nxevent.c +++ b/testing/ostest/nxevent.c @@ -281,7 +281,7 @@ void nxevent_test(void) /* Lower priority */ - sparam.sched_priority = PTHREAD_DEFAULT_PRIORITY; + sparam.sched_priority = PRIORITY; pthread_attr_setschedparam(&attr, &sparam); /* Create thread */ @@ -304,7 +304,7 @@ void nxevent_test(void) /* Lower priority */ - sparam.sched_priority = PTHREAD_DEFAULT_PRIORITY; + sparam.sched_priority = PRIORITY; pthread_attr_setschedparam(&attr, &sparam); /* Create thread */ diff --git a/testing/ostest/prioinherit.c b/testing/ostest/prioinherit.c index a9ffe3d4fe9..3e8bc1010cf 100644 --- a/testing/ostest/prioinherit.c +++ b/testing/ostest/prioinherit.c @@ -516,7 +516,7 @@ void priority_inheritance(void) { printf("priority_inheritance: ERROR sched_getparam failed\n"); ASSERT(false); - sparam.sched_priority = PTHREAD_DEFAULT_PRIORITY; + sparam.sched_priority = PRIORITY; } my_pri = sparam.sched_priority; diff --git a/testing/ostest/schedlock.c b/testing/ostest/schedlock.c index 69d2ef0a387..4799329a10e 100644 --- a/testing/ostest/schedlock.c +++ b/testing/ostest/schedlock.c @@ -164,7 +164,7 @@ void sched_lock_test(void) { printf("sched_lock: ERROR sched_getparam failed\n"); ASSERT(false); - sparam.sched_priority = PTHREAD_DEFAULT_PRIORITY; + sparam.sched_priority = PRIORITY; } highprio = sparam.sched_priority - 2; diff --git a/testing/ostest/sem.c b/testing/ostest/sem.c index 4de91c49bf2..015b3726e82 100644 --- a/testing/ostest/sem.c +++ b/testing/ostest/sem.c @@ -166,10 +166,9 @@ void sem_test(void) pthread_addr_t result; #endif struct sched_param sparam; + pthread_attr_t attr; int prio_min; int prio_max; - int prio_mid; - pthread_attr_t attr; int status; printf("sem_test: Initializing semaphore to 0\n"); @@ -184,11 +183,9 @@ void sem_test(void) printf("sem_test: pthread_attr_init failed, status=%d\n", status); } - prio_min = sched_get_priority_min(SCHED_FIFO); prio_max = sched_get_priority_max(SCHED_FIFO); - prio_mid = (prio_min + prio_max) / 2; - - sparam.sched_priority = (prio_mid + prio_max) / 2; + sparam.sched_priority = PRIORITY + 10 <= prio_max ? + PRIORITY + 10 : prio_max; status = pthread_attr_setschedparam(&attr, &sparam); if (status != OK) { @@ -220,7 +217,7 @@ void sem_test(void) ASSERT(false); } - sparam.sched_priority = prio_mid; + sparam.sched_priority = PRIORITY; status = pthread_attr_setschedparam(&attr, &sparam); if (status != OK) { @@ -260,7 +257,9 @@ void sem_test(void) ASSERT(false); } - sparam.sched_priority = (prio_min + prio_mid) / 2; + prio_min = sched_get_priority_min(SCHED_FIFO); + sparam.sched_priority = PRIORITY - 10 >= prio_min ? + PRIORITY - 10 : prio_min; status = pthread_attr_setschedparam(&attr, &sparam); if (status != OK) { diff --git a/testing/ostest/semtimed.c b/testing/ostest/semtimed.c index ce3f163c111..81f9f9e9fa3 100644 --- a/testing/ostest/semtimed.c +++ b/testing/ostest/semtimed.c @@ -105,11 +105,10 @@ void semtimed_test(void) struct timespec abstime; struct timespec before; struct timespec after; - int prio_min; - int prio_max; - int prio_mid; int errcode; pthread_attr_t attr; + int prio_min; + int prio_max; int status; printf("semtimed_test: Initializing semaphore to 0\n"); @@ -174,11 +173,9 @@ void semtimed_test(void) ASSERT(false); } - prio_min = sched_get_priority_min(SCHED_FIFO); prio_max = sched_get_priority_max(SCHED_FIFO); - prio_mid = (prio_min + prio_max) / 2; - - sparam.sched_priority = (prio_mid + prio_max) / 2; + sparam.sched_priority = PRIORITY + 10 <= prio_max ? + PRIORITY + 10 : prio_max; status = pthread_attr_setschedparam(&attr, &sparam); if (status != OK) { @@ -201,7 +198,9 @@ void semtimed_test(void) ASSERT(false); } - sparam.sched_priority = (prio_min + prio_mid) / 2; + prio_min = sched_get_priority_min(SCHED_FIFO); + sparam.sched_priority = PRIORITY - 10 >= prio_min ? + PRIORITY - 10 : prio_min; status = pthread_attr_setschedparam(&attr, &sparam); if (status != OK) { diff --git a/testing/ostest/sighand.c b/testing/ostest/sighand.c index c368a37f1e3..cafd068c074 100644 --- a/testing/ostest/sighand.c +++ b/testing/ostest/sighand.c @@ -276,7 +276,7 @@ void sighand_test(void) { printf("sighand_test: ERROR sched_getparam() failed\n"); ASSERT(false); - param.sched_priority = PTHREAD_DEFAULT_PRIORITY; + param.sched_priority = PRIORITY; } pthread_attr_init(&attr); diff --git a/testing/ostest/signest.c b/testing/ostest/signest.c index 5e8e6596140..42b67c2f4a7 100644 --- a/testing/ostest/signest.c +++ b/testing/ostest/signest.c @@ -300,7 +300,7 @@ void signest_test(void) { printf("signest_test: ERROR sched_getparam() failed\n"); ASSERT(false); - param.sched_priority = PTHREAD_DEFAULT_PRIORITY; + param.sched_priority = PRIORITY; } /* Start waiter thread */ diff --git a/testing/ostest/suspend.c b/testing/ostest/suspend.c index a1d6f6b877c..490314884be 100644 --- a/testing/ostest/suspend.c +++ b/testing/ostest/suspend.c @@ -77,7 +77,7 @@ void suspend_test(void) { printf("suspend_test: ERROR sched_getparam() failed\n"); ASSERT(false); - param.sched_priority = PTHREAD_DEFAULT_PRIORITY; + param.sched_priority = PRIORITY; } victim = task_create("victim", param.sched_priority, diff --git a/testing/ostest/timedwait.c b/testing/ostest/timedwait.c index ab3f6794cc3..44bfd72503c 100644 --- a/testing/ostest/timedwait.c +++ b/testing/ostest/timedwait.c @@ -166,7 +166,7 @@ void timedwait_test(void) if (status != 0) { printf("timedwait_test: sched_getparam failed\n"); - sparam.sched_priority = PTHREAD_DEFAULT_PRIORITY; + sparam.sched_priority = PRIORITY; } sparam.sched_priority = (prio_max + sparam.sched_priority) / 2; From 4e2be7a8822d58adfb10862658a5cbfc36e7e06f Mon Sep 17 00:00:00 2001 From: yangao1 Date: Thu, 6 Nov 2025 19:58:06 +0800 Subject: [PATCH 2/4] ostest:modify ostest task priority ostest sometimes fail because other threads with higher priority are running, we add ostest priority kconfig, so that we can increase ostest priority easier. Signed-off-by: yangao1 --- testing/ostest/CMakeLists.txt | 12 +++++++++++- testing/ostest/Kconfig | 4 ++++ testing/ostest/Makefile | 2 +- testing/ostest/ostest.h | 20 +++++++++++++++----- testing/ostest/ostest_main.c | 20 ++++++-------------- testing/ostest/pthread_exit.c | 6 ------ testing/ostest/restart.c | 15 ++++----------- testing/ostest/waitpid.c | 8 -------- 8 files changed, 41 insertions(+), 46 deletions(-) diff --git a/testing/ostest/CMakeLists.txt b/testing/ostest/CMakeLists.txt index 6e971373dd1..1d24bcfc972 100644 --- a/testing/ostest/CMakeLists.txt +++ b/testing/ostest/CMakeLists.txt @@ -162,6 +162,16 @@ if(CONFIG_TESTING_OSTEST) endif() set(OSTEST_SRCS ostest_main.c ${SRCS}) - nuttx_add_application(NAME ostest SRCS ${OSTEST_SRCS}) + nuttx_add_application( + MODULE + ${CONFIG_TESTING_OSTEST} + NAME + ostest + SRCS + ${OSTEST_SRCS} + STACKSIZE + ${CONFIG_TESTING_OSTEST_STACKSIZE} + PRIORITY + ${CONFIG_TESTING_OSTEST_PRIORITY}) endif() diff --git a/testing/ostest/Kconfig b/testing/ostest/Kconfig index 83054fa688a..5c58244afad 100644 --- a/testing/ostest/Kconfig +++ b/testing/ostest/Kconfig @@ -18,6 +18,10 @@ config TESTING_OSTEST_LOOPS Used to control the number of executions of the test. If undefined, the test executes one time. If defined to be zero, the test runs forever. +config TESTING_OSTEST_PRIORITY + int "OS test task priority" + default 150 + config TESTING_OSTEST_STACKSIZE int "OS test stack size" default 8192 diff --git a/testing/ostest/Makefile b/testing/ostest/Makefile index 5f7d5d4f823..3e58c43c241 100644 --- a/testing/ostest/Makefile +++ b/testing/ostest/Makefile @@ -25,7 +25,7 @@ include $(APPDIR)/Make.defs # ostest built-in application info PROGNAME = ostest -PRIORITY = SCHED_PRIORITY_DEFAULT +PRIORITY = $(CONFIG_TESTING_OSTEST_PRIORITY) STACKSIZE = $(CONFIG_DEFAULT_TASK_STACKSIZE) MODULE = $(CONFIG_TESTING_OSTEST) diff --git a/testing/ostest/ostest.h b/testing/ostest/ostest.h index 321ecd2d330..ce0be3f6070 100644 --- a/testing/ostest/ostest.h +++ b/testing/ostest/ostest.h @@ -36,14 +36,24 @@ * Pre-processor Definitions ****************************************************************************/ -/* The task_create task size can be specified in the defconfig file */ +#define OSTEST_NARGS 4 +#define RESTART_NARGS 3 -#ifdef CONFIG_TESTING_OSTEST_STACKSIZE -# define STACKSIZE CONFIG_TESTING_OSTEST_STACKSIZE -#else -# define STACKSIZE 8192 +#define HALF_SECOND_USEC 500000L +#define RETURN_STATUS 14 + +#ifdef CONFIG_SCHED_WAITPID +# define NCHILDREN 3 #endif +/* The task_create priority can be specified in the defconfig file */ + +#define PRIORITY CONFIG_TESTING_OSTEST_PRIORITY + +/* The task_create task size can be specified in the defconfig file */ + +#define STACKSIZE CONFIG_TESTING_OSTEST_STACKSIZE + /* The number of times to execute the test can be specified in the defconfig * file. */ diff --git a/testing/ostest/ostest_main.c b/testing/ostest/ostest_main.c index 48dc94da79d..0bc8629cb7f 100644 --- a/testing/ostest/ostest_main.c +++ b/testing/ostest/ostest_main.c @@ -46,14 +46,6 @@ #include "ostest.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -#define PRIORITY 100 -#define NARGS 4 -#define HALF_SECOND_USEC 500000L - /**************************************************************************** * Private Data ****************************************************************************/ @@ -72,9 +64,9 @@ static const char write_data2[] = "stdio_test: write fd=2\n"; * pointer types. */ -static const char *g_argv[NARGS + 1]; +static const char *g_argv[OSTEST_NARGS + 1]; #else -static const char *g_argv[NARGS + 1] = +static const char *g_argv[OSTEST_NARGS + 1] = { arg1, arg2, arg3, arg4, NULL }; @@ -229,19 +221,19 @@ static int user_main(int argc, char *argv[]) /* Verify passed arguments */ - if (argc != NARGS + 1) + if (argc != OSTEST_NARGS + 1) { printf("user_main: ERROR expected argc=%d got argc=%d\n", - NARGS + 1, argc); + OSTEST_NARGS + 1, argc); ASSERT(false); } - for (i = 0; i <= NARGS; i++) + for (i = 0; i <= OSTEST_NARGS; i++) { printf("user_main: argv[%d]=\"%s\"\n", i, argv[i]); } - for (i = 1; i <= NARGS; i++) + for (i = 1; i <= OSTEST_NARGS; i++) { if (strcmp(argv[i], g_argv[i - 1]) != 0) { diff --git a/testing/ostest/pthread_exit.c b/testing/ostest/pthread_exit.c index bc4ca5eac5e..489f7e91b5c 100644 --- a/testing/ostest/pthread_exit.c +++ b/testing/ostest/pthread_exit.c @@ -37,12 +37,6 @@ #ifdef CONFIG_SCHED_WAITPID -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -#define PRIORITY 100 - /**************************************************************************** * Private Functions ****************************************************************************/ diff --git a/testing/ostest/restart.c b/testing/ostest/restart.c index 891a5b5d663..4dbad68b3e4 100644 --- a/testing/ostest/restart.c +++ b/testing/ostest/restart.c @@ -40,18 +40,11 @@ #ifndef CONFIG_BUILD_KERNEL -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -#define PRIORITY 100 -#define NARGS 3 - /**************************************************************************** * Private Data ****************************************************************************/ -static char * const g_argv[NARGS + 1] = +static char * const g_argv[RESTART_NARGS + 1] = { "This is argument 1", "Argument 2 here", @@ -83,14 +76,14 @@ static int restart_main(int argc, char *argv[]) /* Verify passed arguments */ - if (argc != NARGS + 1) + if (argc != RESTART_NARGS + 1) { printf("restart_main: ERROR: Expected argc=%d got argc=%d\n", - NARGS + 1, argc); + RESTART_NARGS + 1, argc); ASSERT(false); } - for (i = 0; i <= NARGS; i++) + for (i = 0; i <= RESTART_NARGS; i++) { printf("restart_main: argv[%d]=\"%s\"\n", i, argv[i]); if (i > 0 && strcmp(argv[i], g_argv[i - 1]) != 0) diff --git a/testing/ostest/waitpid.c b/testing/ostest/waitpid.c index 2be66e8c944..bbc2075d7f8 100644 --- a/testing/ostest/waitpid.c +++ b/testing/ostest/waitpid.c @@ -43,14 +43,6 @@ #if defined(CONFIG_SCHED_WAITPID) && !defined(CONFIG_BUILD_KERNEL) -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -#define RETURN_STATUS 14 -#define NCHILDREN 3 -#define PRIORITY 100 - /**************************************************************************** * Private Data ****************************************************************************/ From 091f0405ad4457d95de7de324a8997c409114cb0 Mon Sep 17 00:00:00 2001 From: guanyi3 Date: Thu, 15 Jan 2026 11:10:44 +0800 Subject: [PATCH 3/4] ostest: fix spelling error fix spelling error reported by codespellrc. Signed-off-by: guanyi3 --- testing/ostest/prioinherit.c | 6 +++--- testing/ostest/signest.c | 2 +- testing/ostest/waitpid.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/testing/ostest/prioinherit.c b/testing/ostest/prioinherit.c index 3e8bc1010cf..63706013dd8 100644 --- a/testing/ostest/prioinherit.c +++ b/testing/ostest/prioinherit.c @@ -352,7 +352,7 @@ static FAR void *lowpri_thread(FAR void *parameter) while (g_middlestate == NOTSTARTED && nhighpri_waiting() < NHIGHPRI_THREADS) { - printf("lowpri_thread-%d: Waiting for the midle pri task to run\n", + printf("lowpri_thread-%d: Waiting for the mid pri task to run\n", threadno); printf(" g_middlestate: %d\n", (int)g_middlestate); for (i = 0; i < NHIGHPRI_THREADS; i++) @@ -403,7 +403,7 @@ static FAR void *lowpri_thread(FAR void *parameter) */ printf("lowpri_thread-%d: %s the middle priority task has already" - " exitted!\n", + " exited!\n", threadno, count >= 0 ? "SUCCESS" : "ERROR"); ASSERT(count >= 0); printf(" g_middlestate: %d sem count=%d\n", @@ -657,7 +657,7 @@ void priority_inheritance(void) if (status != 0) { printf("priority_inheritance: " - "ERRROR pthread_create failed, status=%d\n", status); + "ERROR pthread_create failed, status=%d\n", status); ASSERT(false); } } diff --git a/testing/ostest/signest.c b/testing/ostest/signest.c index 42b67c2f4a7..0a45115496b 100644 --- a/testing/ostest/signest.c +++ b/testing/ostest/signest.c @@ -532,7 +532,7 @@ void signest_test(void) total_handled = g_odd_handled + g_even_handled; total_nested = g_odd_nested + g_even_nested; - printf("signest_test: With intefering thread\n"); + printf("signest_test: With interfering thread\n"); printf(" Total signalled %-3d Odd=%-3d Even=%-3d\n", total_signals, odd_signals, even_signals); printf(" Total handled %-3d Odd=%-3d Even=%-3d\n", diff --git a/testing/ostest/waitpid.c b/testing/ostest/waitpid.c index bbc2075d7f8..c344fb6e2a6 100644 --- a/testing/ostest/waitpid.c +++ b/testing/ostest/waitpid.c @@ -59,7 +59,7 @@ static int waitpid_main(int argc, char *argv[]) printf("waitpid_main: PID %d Started\n", me); sleep(3); - printf("waitpid_main: PID %d exitting with result=%d\n", + printf("waitpid_main: PID %d exiting with result=%d\n", me, RETURN_STATUS); return RETURN_STATUS; } From d3419a96eed598054b56814794aba32eb7609594 Mon Sep 17 00:00:00 2001 From: yangao1 Date: Mon, 8 Dec 2025 15:46:10 +0800 Subject: [PATCH 4/4] ostest/cancel.c: fix busyloop after improving ostest priority Because the priority of ostest was increased, the priority of the main thread also increased. Newly created threads still used the default priority, causing the parent thread to prematurely cancel the child thread. This resulted in the child thread not being properly garbage collected, leading to a system busy loop. Signed-off-by: yangao1 --- testing/ostest/cancel.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/testing/ostest/cancel.c b/testing/ostest/cancel.c index 907a69354d6..2382a411642 100644 --- a/testing/ostest/cancel.c +++ b/testing/ostest/cancel.c @@ -287,8 +287,8 @@ static FAR void *asynch_waiter(FAR void *parameter) ASSERT(false); } - /* Then wait a bit. We should be canceled aynchronously while waiting, but - * the cancellation should pend because we are non-cancellable. + /* Then wait a bit. We should be canceled asynchronously while waiting, + * but the cancellation should pend because we are non-cancelable. */ usleep(250 * 1000); @@ -321,6 +321,7 @@ static FAR void *asynch_waiter(FAR void *parameter) static void start_thread(FAR void *(*entry)(FAR void *), pthread_t *waiter, int cancelable) { + struct sched_param param; pthread_attr_t attr; int status; @@ -356,6 +357,18 @@ static void start_thread(FAR void *(*entry)(FAR void *), pthread_t *waiter, ASSERT(false); } + param.sched_priority = PRIORITY; + printf("start_thread: Parent thread priority=%d\n", + param.sched_priority); + + status = pthread_attr_setschedparam(&attr, ¶m); + if (status != 0) + { + printf("start_thread: ERROR pthread_attr_setschedparam failed," + "status=%d\n", status); + ASSERT(false); + } + status = pthread_attr_setstacksize(&attr, STACKSIZE); if (status != 0) {