Commit 04e1d7d
committed
[kernel/signal] fix: respect suspend state when delivering signals
Native signal delivery resumed every suspended thread, including
RT_UNINTERRUPTIBLE IPC waiters. This could remove a waiter from a
semaphore, mutex, event, mailbox, or message queue wait list without
granting the corresponding resource, causing -RT_EINTR or inconsistent
higher-level state.
Inspect pending signals and suspend state under scheduler ownership.
Wake interruptible waiters for common signals, and wake killable waiters
only for SIGKILL and SIGSTOP according to RT-Thread suspend semantics.
Defer signals not allowed by the current wait mode. Release the signal
lock before waking the target thread. Also make scheduler-side
pending-signal preprocessing respect the suspend mode, preventing SMP
suspend-to-schedule races.
Keep rt_signal_wait() blocked for non-matching signals and preserve the
remaining timeout. Allow masked signals and NULL siginfo, handle suspend
failures without starting a timer, and preserve the outer interrupted
wait result when a signal handler invokes other kernel APIs.
Add regression coverage for RT-Thread native signal semantics,
including masked signals, non-matching signal waits, NULL siginfo,
and RT_KILLABLE SIGSTOP handling. The parent implementation fails the
regression test because uninterruptible and killable waits complete early
after SIGUSR1, and signal_wait returns early for a non-matching signal.
Validation:
- UP QEMU: core.signal passed.
- Dual-core SMP QEMU: core.signal passed.
- scons -C bsp/qemu-vexpress-a9 -j$(nproc) passed.
Signed-off-by: Hui Su <3164683437@qq.com>1 parent 8234a36 commit 04e1d7d
4 files changed
Lines changed: 679 additions & 122 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
587 | 587 | | |
588 | 588 | | |
589 | 589 | | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
590 | 595 | | |
591 | 596 | | |
592 | 597 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
713 | 713 | | |
714 | 714 | | |
715 | 715 | | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
716 | 740 | | |
717 | 741 | | |
718 | 742 | | |
| |||
727 | 751 | | |
728 | 752 | | |
729 | 753 | | |
730 | | - | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
731 | 757 | | |
732 | 758 | | |
733 | 759 | | |
| |||
0 commit comments