You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/05/20 13:53:47 UTC
[GitHub] [incubator-nuttx-apps] davids5 opened a new pull request, #1168: ostest:priority_inheritance Added priority restoration test
davids5 opened a new pull request, #1168:
URL: https://github.com/apache/incubator-nuttx-apps/pull/1168
## Summary
See https://github.com/apache/incubator-nuttx/issues/6310
## Impact
Loss of system priorities
## Testing
master nuttx
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx-apps] xiaoxiang781216 commented on a diff in pull request #1168: ostest:priority_inheritance Added priority restoration test
Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #1168:
URL: https://github.com/apache/incubator-nuttx-apps/pull/1168#discussion_r878231510
##########
testing/ostest/prioinherit.c:
##########
@@ -88,10 +92,76 @@ static sem_t g_sem;
static volatile enum thstate_e g_middlestate;
static volatile enum thstate_e g_highstate[NHIGHPRI_THREADS];
static volatile enum thstate_e g_lowstate[NLOWPRI_THREADS];
+static volatile int g_priority_tracking[NUMBER_OF_COMPETING_THREADS];
static int g_highpri;
static int g_medpri;
static int g_lowpri;
+/****************************************************************************
+ * Name: sleep_and_display
+ ****************************************************************************/
+
+static void sleep_and_display(int n, int us)
+{
+ struct sched_param sparam;
+
+ us /= 100;
+
+ do
+ {
+ int status = sched_getparam (getpid(), &sparam);
+
+ if (status != 0)
+ {
+ printf("priority_inheritance: sched_getparam failed\n");
+ }
+
+ if (us == 0 || g_priority_tracking[n] != sparam.sched_priority)
Review Comment:
remove extra space
##########
testing/ostest/prioinherit.c:
##########
@@ -88,10 +92,76 @@ static sem_t g_sem;
static volatile enum thstate_e g_middlestate;
static volatile enum thstate_e g_highstate[NHIGHPRI_THREADS];
static volatile enum thstate_e g_lowstate[NLOWPRI_THREADS];
+static volatile int g_priority_tracking[NUMBER_OF_COMPETING_THREADS];
static int g_highpri;
static int g_medpri;
static int g_lowpri;
+/****************************************************************************
+ * Name: sleep_and_display
+ ****************************************************************************/
+
+static void sleep_and_display(int n, int us)
+{
+ struct sched_param sparam;
+
+ us /= 100;
+
+ do
+ {
+ int status = sched_getparam (getpid(), &sparam);
Review Comment:
remove space before (
##########
testing/ostest/prioinherit.c:
##########
@@ -416,6 +487,12 @@ void priority_inheritance(void)
int my_pri;
int status;
int i;
+ char pids[NUMBER_OF_COMPETING_THREADS];
Review Comment:
pid_t
##########
testing/ostest/prioinherit.c:
##########
@@ -416,6 +487,12 @@ void priority_inheritance(void)
int my_pri;
int status;
int i;
+ char pids[NUMBER_OF_COMPETING_THREADS];
+ char args[3][32];
+ char *argv[4];
Review Comment:
add FAR
##########
testing/ostest/prioinherit.c:
##########
@@ -588,6 +665,61 @@ void priority_inheritance(void)
dump_nfreeholders("priority_inheritance:");
}
+ /* Perform restoration test */
+
+ printf("priority_inheritance: Restoration Test:\n");
+
+ sem_init(&g_sem, 0, 1);
+ priority = COMPETING_THREAD_START_PRIORITY;
+ argv[0] = args[0];
+ argv[1] = args[1];
+ argv[2] = args[2];
+ argv[3] = NULL;
+
+ for (i = 0; i < NUMBER_OF_COMPETING_THREADS; i++)
+ {
+ g_priority_tracking[i] = 0;
+ snprintf(name, sizeof(name), "Task%1d", i);
+ snprintf(args[0], sizeof(args[0]), "%d", i);
+ snprintf(args[1], sizeof(args[1]), "%d", i * 10000);
+ snprintf(args[2], sizeof(args[2]), "%d", i == 0 ? 100000 : 1000);
+
+ pids[i] = task_create(name, priority, 1024, adversary,
+ (FAR char * const *) argv);
Review Comment:
remove space before args
##########
testing/ostest/prioinherit.c:
##########
@@ -88,10 +93,76 @@ static sem_t g_sem;
static volatile enum thstate_e g_middlestate;
static volatile enum thstate_e g_highstate[NHIGHPRI_THREADS];
static volatile enum thstate_e g_lowstate[NLOWPRI_THREADS];
+static volatile int g_priority_tracking[NUMBER_OF_COMPETING_THREADS];
static int g_highpri;
static int g_medpri;
static int g_lowpri;
+/****************************************************************************
+ * Name: sleep_and_display
+ ****************************************************************************/
+
+static void sleep_and_display(int n, int us)
+{
+ struct sched_param sparam;
+
+ us /= 100;
+
+ do
+ {
+ int status = sched_getparam (getpid(), &sparam);
+
+ if (status != 0)
+ {
+ printf("priority_inheritance: sched_getparam failed\n");
+ }
+
+ if (us == 0 || g_priority_tracking[n] != sparam.sched_priority)
+ {
+ if (g_priority_tracking[n] == 0)
+ {
+ printf("priority_inheritance: "
+ "Task%1d initial priority is:%d\n",
+ n, sparam.sched_priority);
+ }
+ else
+ {
+ printf("priority_inheritance: "
+ "Task%1d priority was:%d is:%d\n",
+ n, g_priority_tracking[n], sparam.sched_priority);
+ }
+
+ g_priority_tracking[n] = sparam.sched_priority;
+ FFLUSH();
+ }
+
+ usleep(100);
+ us--;
+ }
+ while (us > 0);
+}
+
+/****************************************************************************
+ *
+ ****************************************************************************/
+
+static int adversary(int argc, char *argv[])
Review Comment:
add FAR
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx-apps] pkarashchenko commented on a diff in pull request #1168: ostest:priority_inheritance Added priority restoration test
Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on code in PR #1168:
URL: https://github.com/apache/incubator-nuttx-apps/pull/1168#discussion_r878461499
##########
testing/ostest/prioinherit.c:
##########
@@ -588,6 +667,61 @@ void priority_inheritance(void)
dump_nfreeholders("priority_inheritance:");
}
+ /* Perform restoration test */
+
+ printf("priority_inheritance: Restoration Test:\n");
+
+ sem_init(&g_sem, 0, 1);
+ priority = COMPETING_THREAD_START_PRIORITY;
+ argv[0] = args[0];
+ argv[1] = args[1];
+ argv[2] = args[2];
+ argv[3] = NULL;
+
+ for (i = 0; i < NUMBER_OF_COMPETING_THREADS; i++)
+ {
+ g_priority_tracking[i] = 0;
+ snprintf(name, sizeof(name), "Task%1d", i);
+ snprintf(args[0], sizeof(args[0]), "%d", i);
+ snprintf(args[1], sizeof(args[1]), "%d", i * 10000);
+ snprintf(args[2], sizeof(args[2]), "%d", i == 0 ? 100000 : 1000);
+
+ pids[i] = task_create(name, priority, 1024, adversary,
+ (FAR char * const *)argv);
+ priority += PRIORIY_SPREED;
+ }
+
+ priority = COMPETING_THREAD_START_PRIORITY;
+ restoration_result = 0;
+ for (i = 0; i < NUMBER_OF_COMPETING_THREADS; i++)
+ {
+ printf("priority_inheritance: "
+ "Waiting for Task-%d to complete\n", i);
+
+ waitpid(pids[i], &status, 0);
+ if (priority != g_priority_tracking[i])
+ {
+ printf("priority_inheritance: "
+ "Task-%d Priority is %d, and was not restored to %d\n",
+ i, g_priority_tracking[i], priority);
+
+ restoration_result |= 1 << i;
+ }
+
+ priority += PRIORIY_SPREED;
+ }
+
+ if (restoration_result != 0)
+ {
+ printf("priority_inheritance: ERROR: FAIL Priorities were not "
+ "correctly restored.\n");
+ }
+ else
+ {
+ printf("priority_inheritance: PASSED Priority were correctly"
+ " restored.\n");
Review Comment:
```suggestion
printf("priority_inheritance: PASSED Priority were correctly"
" restored.\n");
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx-apps] pkarashchenko merged pull request #1168: ostest:priority_inheritance Added priority restoration test
Posted by GitBox <gi...@apache.org>.
pkarashchenko merged PR #1168:
URL: https://github.com/apache/incubator-nuttx-apps/pull/1168
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx-apps] masayuki2009 commented on pull request #1168: ostest:priority_inheritance Added priority restoration test
Posted by GitBox <gi...@apache.org>.
masayuki2009 commented on PR #1168:
URL: https://github.com/apache/incubator-nuttx-apps/pull/1168#issuecomment-1136638837
I noticed that `qemu-intel64:ostest` causes a deadlock.
```
SeaBIOS (version rel-1.12.0-59-gc9ba5276e321-prebuilt.qemu.org)
iPXE (http://ipxe.org) 00:03.0 CA00 PCI2.10 PnP PMM+0FF907F0+0FEF07F0 CA00
Booting from Hard Disk...
Boot failed: could not read the boot disk
Booting from Floppy...
Boot failed: could not read the boot disk
Booting from DVD/CD...
stdio_test: write fd=1
stdio_test: Standard I/O Check: printf
stdio_test: write fd=2
ostest_main: putenv(Variable1=BadValue3)
ostest_main: setenv(Variable1, GoodValue1, TRUE)
ostest_main: setenv(Variable2, BadValue1, FALSE)
ostest_main: setenv(Variable2, GoodValue2, TRUE)
ostest_main: setenv(Variable3, Variable3, FALSE)
ostest_main: setenv(Variable3, Variable3, FALSE)
show_variable: Variable=Variable1 has value=GoodValue1
show_variable: Variable=Variable2 has value=GoodValue2
show_variable: Variable=Variable3 has value=GoodValue3
ostest_main: Started user_main at PID=2
...
user_main: priority inheritance test
priority_inheritance: Started
priority_inheritance: Starting lowpri_thread-1 (of 3) at 1
priority_inheritance: Set lowpri_thread-1 priority to 1
priority_inheritance: Starting lowpri_thread-2 (of 3) at 1
priority_inheritance: Set lowpri_thread-2 priority to 1
priority_inheritance: Starting lowpri_thread-3 (of 3) at 1
priority_inheritance: Set lowpri_thread-3 priority to 1
priority_inheritance: Waiting...
lowpri_thread-1: Started
lowpri_thread-1: initial priority: 1
lowpri_thread-1: Waiting for the midle pri task to run
g_middlestate: 0
g_highstate[0]: 0
g_highstate[1]: 0
g_highstate[2]: 0
I still have a count on the semaphore
lowpri_thread-2: Started
lowpri_thread-2: initial priority: 1
lowpri_thread-2: Waiting for the midle pri task to run
g_middlestate: 0
g_highstate[0]: 0
g_highstate[1]: 0
g_highstate[2]: 0
I still have a count on the semaphore
lowpri_thread-3: Started
lowpri_thread-3: initial priority: 1
lowpri_thread-3: Waiting for the midle pri task to run
g_middlestate: 0
g_highstate[0]: 0
g_highstate[1]: 0
g_highstate[2]: 0
I still have a count on the semaphore
lowpri_thread-1: Waiting for the midle pri task to run
g_middlestate: 0
g_highstate[0]: 0
g_highstate[1]: 0
g_highstate[2]: 0
I still have a count on the semaphore
lowpri_thread-2: Waiting for the midle pri task to run
g_middlestate: 0
g_highstate[0]: 0
g_highstate[1]: 0
g_highstate[2]: 0
I still have a count on the semaphore
lowpri_thread-3: Waiting for the midle pri task to run
g_middlestate: 0
g_highstate[0]: 0
g_highstate[1]: 0
g_highstate[2]: 0
I still have a count on the semaphore
priority_inheritance: Starting medpri_thread at 99
priority_inheritance: Set medpri_thread priority to 99
priority_inheritance: Waiting...
medpri_thread: Started ... I won't let go of the CPU!
priority_inheritance: Starting highpri_thread-1 (of 3) at 255
priority_inheritance: Set highpri_thread-1 priority to 255
highpri_thread-1: Started
priority_inheritance: Starting highpri_thread-2 (of 3) at 255
priority_inheritance: Set highpri_thread-2 priority to 254
highpri_thread-2: Started
priority_inheritance: Starting highpri_thread-3 (of 3) at 255
priority_inheritance: Set highpri_thread-3 priority to 253
highpri_thread-3: Started
priority_inheritance: Waiting for highpri_thread-1 to complete
highpri_thread-1: Calling sem_wait()
lowpri_thread-3: Sem count: -1, No. highpri thread: 1
highpri_thread-1: SUCCESS midpri_thread is still running!
highpri_thread-1: Okay... I'm done!
priority_inheritance: Waiting for highpri_thread-2 to complete
highpri_thread-2: Calling sem_wait()
highpri_thread-2: SUCCESS midpri_thread is still running!
highpri_thread-2: Okay... I'm done!
priority_inheritance: Waiting for highpri_thread-3 to complete
highpri_thread-3: Calling sem_wait()
highpri_thread-3: SUCCESS midpri_thread is still running!
highpri_thread-3: Okay... I'm done!
priority_inheritance: Waiting for medpri_thread to complete
medpri_thread: Okay... I'm done!
priority_inheritance: Waiting for lowpri_thread-1 to complete
lowpri_thread-2: Sem count: 1, No. highpri thread: 0
lowpri_thread-2: SUCCESS the middle priority task has already exitted!
g_middlestate: 3 sem count=1
g_highstate[0]: 3
g_highstate[1]: 3
g_highstate[2]: 3
lowpri_thread-2: SUCCESS priority before sem_post: 1
lowpri_thread-2: SUCCESS final priority: 1
lowpri_thread-2: Okay... I'm done!
lowpri_thread-1: Sem count: 2, No. highpri thread: 0
lowpri_thread-1: SUCCESS the middle priority task has already exitted!
g_middlestate: 3 sem count=2
g_highstate[0]: 3
g_highstate[1]: 3
g_highstate[2]: 3
lowpri_thread-1: SUCCESS priority before sem_post: 1
lowpri_thread-1: SUCCESS final priority: 1
lowpri_thread-1: Okay... I'm done!
priority_inheritance: Waiting for lowpri_thread-2 to complete
priority_inheritance: Waiting for lowpri_thread-3 to complete
lowpri_thread-3: SUCCESS priority before sem_post: 255
lowpri_thread-3: SUCCESS final priority: 1
lowpri_thread-3: Okay... I'm done!
priority_inheritance: Restoration Test:
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org