diff options
-rw-r--r-- | apps/examples/ostest/waitpid.c | 93 | ||||
-rw-r--r-- | nuttx/configs/stm32f3discovery/nsh/defconfig | 4 | ||||
-rw-r--r-- | nuttx/configs/stm32f3discovery/ostest/defconfig | 9 | ||||
-rw-r--r-- | nuttx/configs/stm32f3discovery/usbnsh/defconfig | 4 | ||||
-rw-r--r-- | nuttx/sched/sched_waitpid.c | 14 |
5 files changed, 104 insertions, 20 deletions
diff --git a/apps/examples/ostest/waitpid.c b/apps/examples/ostest/waitpid.c index d45410265..67cd81fdc 100644 --- a/apps/examples/ostest/waitpid.c +++ b/apps/examples/ostest/waitpid.c @@ -110,8 +110,23 @@ static void waitpid_last(void) if (ret < 0) { int errcode = errno; - printf("waitpid_last: ERROR: PID %d waitpid failed: %d\n", - g_waitpids[NCHILDREN-1], errcode); + + /* Unfortunately, this main thread does not retain child status. If + * child status is enabled (via CONFIG_SCHED_CHILD_STATUS), ostest_main() + * disables the feature by calling sigactin with SA_NOCLDWAIT. + */ + + if (errcode == ECHILD) + { + printf("waitpid_last: PASS: PID %d waitpid failed with ECHILD. That may be\n", + g_waitpids[NCHILDREN-1]); + printf(" acceptable because child status is disabled on this thread.\n"); + } + else + { + printf("waitpid_last: ERROR: PID %d waitpid failed: %d\n", + g_waitpids[NCHILDREN-1], errcode); + } } else if (WEXITSTATUS(stat_loc) != RETURN_STATUS) { @@ -120,7 +135,7 @@ static void waitpid_last(void) } else { - printf("waitpid_last: PID %d waitpid succeeded with stat_loc=%04x\n", + printf("waitpid_last: PASS: PID %d waitpid succeeded with stat_loc=%04x\n", g_waitpids[NCHILDREN-1], stat_loc); } } @@ -147,8 +162,23 @@ int waitpid_test(void) if (ret < 0) { int errcode = errno; - printf("waitpid_test: ERROR: PID %d waitpid failed: %d\n", - g_waitpids[0], errcode); + + /* Unfortunately, this main thread does not retain child status. If + * child status is enabled (via CONFIG_SCHED_CHILD_STATUS), ostest_main() + * disables the feature by calling sigactin with SA_NOCLDWAIT. + */ + + if (errcode == ECHILD) + { + printf("waitpid_test: PASS: PID %d waitpid failed with ECHILD. That may be\n", + g_waitpids[NCHILDREN-1]); + printf(" acceptable because child status is disabled on this thread.\n"); + } + else + { + printf("waitpid_test: ERROR: PID %d waitpid failed: %d\n", + g_waitpids[0], errcode); + } } else if (ret != g_waitpids[0]) { @@ -182,8 +212,23 @@ int waitpid_test(void) if (ret < 0) { int errcode = errno; - printf("waitpid_test: ERROR: PID %d waitid failed: %d\n", - g_waitpids[0], errcode); + + /* Unfortunately, this main thread does not retain child status. If + * child status is enabled (via CONFIG_SCHED_CHILD_STATUS), ostest_main() + * disables the feature by calling sigactin with SA_NOCLDWAIT. + */ + + if (errcode == ECHILD) + { + printf("waitpid_test: PASS: PID %d waitpid failed with ECHILD. That may be\n", + g_waitpids[NCHILDREN-1]); + printf(" acceptable because child status is disabled on this thread.\n"); + } + else + { + printf("waitpid_test: ERROR: PID %d waitid failed: %d\n", + g_waitpids[0], errcode); + } } else if (info.si_pid != g_waitpids[0]) { @@ -216,7 +261,22 @@ int waitpid_test(void) if (ret < 0) { int errcode = errno; - printf("waitpid_test: ERROR: waitid failed: %d\n", errcode); + + /* Unfortunately, this main thread does not retain child status. If + * child status is enabled (via CONFIG_SCHED_CHILD_STATUS), ostest_main() + * disables the feature by calling sigactin with SA_NOCLDWAIT. + */ + + if (errcode == ECHILD) + { + printf("waitpid_test: PASS: PID %d waitpid failed with ECHILD. That may be\n", + g_waitpids[NCHILDREN-1]); + printf(" acceptable because child status is disabled on this thread.\n"); + } + else + { + printf("waitpid_test: ERROR: waitid failed: %d\n", errcode); + } } else if (info.si_status != RETURN_STATUS) { @@ -244,7 +304,22 @@ int waitpid_test(void) if (ret < 0) { int errcode = errno; - printf("waitpid_test: ERROR: wait failed: %d\n", errcode); + + /* Unfortunately, this main thread does not retain child status. If + * child status is enabled (via CONFIG_SCHED_CHILD_STATUS), ostest_main() + * disables the feature by calling sigactin with SA_NOCLDWAIT. + */ + + if (errcode == ECHILD) + { + printf("waitpid_test: PASS: PID %d waitpid failed with ECHILD. That may be\n", + g_waitpids[NCHILDREN-1]); + printf(" acceptable because child status is disabled on this thread.\n"); + } + else + { + printf("waitpid_test: ERROR: wait failed: %d\n", errcode); + } } else if (WEXITSTATUS(stat_loc) != RETURN_STATUS) { diff --git a/nuttx/configs/stm32f3discovery/nsh/defconfig b/nuttx/configs/stm32f3discovery/nsh/defconfig index c487c0296..4b81a70ad 100644 --- a/nuttx/configs/stm32f3discovery/nsh/defconfig +++ b/nuttx/configs/stm32f3discovery/nsh/defconfig @@ -87,7 +87,7 @@ CONFIG_ARCH_HAVE_CMNVECTOR=y # CONFIG_ARCH_FPU is not set CONFIG_ARCH_HAVE_MPU=y # CONFIG_ARMV7M_MPU is not set -CONFIG_BOARD_LOOPSPERMSEC=16717 +CONFIG_BOARD_LOOPSPERMSEC=6522 # CONFIG_ARCH_CALIBRATION is not set # @@ -173,13 +173,13 @@ CONFIG_STM32_SYSCFG=y # CONFIG_STM32_TIM2 is not set # CONFIG_STM32_TIM3 is not set # CONFIG_STM32_TIM4 is not set -# CONFIG_STM32_TIM5 is not set # CONFIG_STM32_TIM6 is not set # CONFIG_STM32_TIM7 is not set # CONFIG_STM32_TIM8 is not set # CONFIG_STM32_TIM15 is not set # CONFIG_STM32_TIM16 is not set # CONFIG_STM32_TIM17 is not set +# CONFIG_STM32_TSC is not set # CONFIG_STM32_USART1 is not set CONFIG_STM32_USART2=y CONFIG_STM32_USB=y diff --git a/nuttx/configs/stm32f3discovery/ostest/defconfig b/nuttx/configs/stm32f3discovery/ostest/defconfig index f5a51ccc5..3db001546 100644 --- a/nuttx/configs/stm32f3discovery/ostest/defconfig +++ b/nuttx/configs/stm32f3discovery/ostest/defconfig @@ -87,7 +87,7 @@ CONFIG_ARCH_HAVE_CMNVECTOR=y # CONFIG_ARCH_FPU is not set CONFIG_ARCH_HAVE_MPU=y # CONFIG_ARMV7M_MPU is not set -CONFIG_BOARD_LOOPSPERMSEC=16717 +CONFIG_BOARD_LOOPSPERMSEC=6522 # CONFIG_ARCH_CALIBRATION is not set # @@ -173,13 +173,13 @@ CONFIG_STM32_SYSCFG=y # CONFIG_STM32_TIM2 is not set # CONFIG_STM32_TIM3 is not set # CONFIG_STM32_TIM4 is not set -# CONFIG_STM32_TIM5 is not set # CONFIG_STM32_TIM6 is not set # CONFIG_STM32_TIM7 is not set # CONFIG_STM32_TIM8 is not set # CONFIG_STM32_TIM15 is not set # CONFIG_STM32_TIM16 is not set # CONFIG_STM32_TIM17 is not set +# CONFIG_STM32_TSC is not set # CONFIG_STM32_USART1 is not set CONFIG_STM32_USART2=y # CONFIG_STM32_USB is not set @@ -268,7 +268,9 @@ CONFIG_MSEC_PER_TICK=10 CONFIG_RR_INTERVAL=200 # CONFIG_SCHED_INSTRUMENTATION is not set CONFIG_TASK_NAME_SIZE=0 -# CONFIG_SCHED_HAVE_PARENT is not set +CONFIG_SCHED_HAVE_PARENT=y +CONFIG_SCHED_CHILD_STATUS=y +CONFIG_PREALLOC_CHILDSTATUS=0 # CONFIG_JULIAN_TIME is not set CONFIG_START_YEAR=2009 CONFIG_START_MONTH=9 @@ -299,6 +301,7 @@ CONFIG_DISABLE_ENVIRON=y CONFIG_SIG_SIGUSR1=1 CONFIG_SIG_SIGUSR2=2 CONFIG_SIG_SIGALARM=3 +CONFIG_SIG_SIGCHLD=4 CONFIG_SIG_SIGCONDTIMEDOUT=16 # diff --git a/nuttx/configs/stm32f3discovery/usbnsh/defconfig b/nuttx/configs/stm32f3discovery/usbnsh/defconfig index 975549815..2f6bd0138 100644 --- a/nuttx/configs/stm32f3discovery/usbnsh/defconfig +++ b/nuttx/configs/stm32f3discovery/usbnsh/defconfig @@ -87,7 +87,7 @@ CONFIG_ARCH_HAVE_CMNVECTOR=y # CONFIG_ARCH_FPU is not set CONFIG_ARCH_HAVE_MPU=y # CONFIG_ARMV7M_MPU is not set -CONFIG_BOARD_LOOPSPERMSEC=16717 +CONFIG_BOARD_LOOPSPERMSEC=6522 # CONFIG_ARCH_CALIBRATION is not set # @@ -173,13 +173,13 @@ CONFIG_STM32_SYSCFG=y # CONFIG_STM32_TIM2 is not set # CONFIG_STM32_TIM3 is not set # CONFIG_STM32_TIM4 is not set -# CONFIG_STM32_TIM5 is not set # CONFIG_STM32_TIM6 is not set # CONFIG_STM32_TIM7 is not set # CONFIG_STM32_TIM8 is not set # CONFIG_STM32_TIM15 is not set # CONFIG_STM32_TIM16 is not set # CONFIG_STM32_TIM17 is not set +# CONFIG_STM32_TSC is not set # CONFIG_STM32_USART1 is not set CONFIG_STM32_USART2=y CONFIG_STM32_USB=y diff --git a/nuttx/sched/sched_waitpid.c b/nuttx/sched/sched_waitpid.c index edd1f3a97..7d1196350 100644 --- a/nuttx/sched/sched_waitpid.c +++ b/nuttx/sched/sched_waitpid.c @@ -350,7 +350,9 @@ pid_t waitpid(pid_t pid, int *stat_loc, int options) } } } -#else + +#else /* CONFIG_SCHED_CHILD_STATUS */ + if (rtcb->nchildren == 0) { /* There are no children */ @@ -373,7 +375,8 @@ pid_t waitpid(pid_t pid, int *stat_loc, int options) goto errout_with_errno; } } -#endif + +#endif /* CONFIG_SCHED_CHILD_STATUS */ /* Loop until the child that we are waiting for dies */ @@ -455,7 +458,9 @@ pid_t waitpid(pid_t pid, int *stat_loc, int options) goto errout_with_errno; } } -#else + +#else /* CONFIG_SCHED_CHILD_STATUS */ + /* Check if the task has already died. Signals are not queued in * NuttX. So a possibility is that the child has died and we * missed the death of child signal (we got some other signal @@ -473,7 +478,8 @@ pid_t waitpid(pid_t pid, int *stat_loc, int options) err = ECHILD; goto errout_with_errno; } -#endif + +#endif /* CONFIG_SCHED_CHILD_STATUS */ /* Wait for any death-of-child signal */ |