zyfeier opened a new pull request, #21605:
URL: https://github.com/apache/nuttx/pull/21605
## Summary
* Why: Without SCHED_HAVE_PARENT, waitpid() waiters were woken before
group_leave(), so the parent could return while the child still had
its files open; and the last member was picked with sq_is_singular()
outside the lock that removes members, so on SMP two members exiting
at once could each see the other and nobody woke the waiters.
* What: sched/task exit path, waitpid() wakeup timing.
* How: Keep writing the exit status where it was (new helper
nxtask_saveexitstatus()), but wake the waiters only when
group_leave() reports the last member, after the files are closed.
group_leave() now returns that decision, taken under tg_lock
together with the removal of the member, so exactly one member of a
group sees it, even when several exit at once. The group is held
across the wakeup, because group_leave() may already have released
it.
## Impact
* Is new feature added? Is existing feature changed? YES - waitpid()
without SCHED_HAVE_PARENT now returns after the child closed its
files; the wakeup no longer races on SMP.
* Impact on user (will user need to adapt to change)? NO
* Impact on build (will build process change)? NO
* Impact on hardware (will arch(s) / board(s) / driver(s) change)? NO
* Impact on documentation (is update required / provided)? NO
* Impact on security (any sort of implications)? NO
* Impact on compatibility (backward/forward/interoperability)? NO -
group_leave() gains a return value; existing callers ignore it.
## Testing
I confirm that changes are verified on local setup and works as intended:
* Build Host(s): Linux x86_64, GCC (host) and aarch64-none-elf-gcc
* Target(s): sim:ostest, qemu-armv8a:nsh_smp
Testing logs (build):
```
CC: task/task_exithook.c
LD: nuttx
```
Testing logs (runtime, sim:ostest, 5 loops):
```
user_main: Exiting
ostest_main: Exiting with status 0
```
Testing logs (runtime, qemu-armv8a:nsh_smp, 4 CPUs):
```
NuttShell (NSH) NuttX 13.1.0
nsh> uname -a
NuttX 13.1.0 03f52b343b6 arm64 qemu-armv8a
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]