walnux/sched
Jukka Laitinen 2b513af2c3 sched/signal/sig_dispatch: Fix race conditions between nxsig_tcbdispatch and nxsig_deliver
For example a race in managing tcb->sigprocmask may cause signal not being delivered at all.
The mechanism is as follows:

1. cpu 1: nxsig_deliver adds the signal to the sigprocmask for the duration of signal delivery
2. cpu 2: new signal (same signo) is dispatched in nxsig_tcbdispatch
3. cpu 2: nxsig_tcbdispatch detects that signal is masked
4. cpu 2: nxsig_tcbdispatch leaves critical section before calling nxsig_add_pendigsignal
5. cpu 1: nxsig_deliver finishes. The "nxsig_unmask_pendingsignal" is called in the end but does nothing
6. cpu 2: nxsig_tcbdispatch continues and adds the pending signal

In the end, the logic in the end of nxsig_deliver, which tries to handle signals added
to the pending queue during the signal action delivery (step 5) failed, and the pending signal
was not delivered.

Fix this by just keeping the critical section for during the whole duration of nxsig_tcbdispatch,
and move things which can't be executed from within critical section outside.

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
2025-05-02 09:21:14 -03:00
..
addrenv sem_waitirq: Use kmap interface to access the semaphore 2024-12-18 08:57:01 +08:00
clock Revert "No need to call sched_lock explicitly after call spin_lock_irqsave, since it will be called in func spin_lock_irqsave." 2025-02-13 14:15:43 +08:00
environ sched/environ: There is no need to use sched_[un]lock 2024-10-11 02:43:11 +08:00
event sched/event: init deleted node to avoid null pointer reference 2024-12-26 23:28:37 +08:00
group group: use tg_mutex to replace tg_joinlock 2025-01-19 17:08:32 +08:00
init sched/init: Fix build error with CONFIG_BOARD_CRASHDUMP_CUSTOM 2025-03-08 00:18:25 +08:00
instrument gprof: move gprof function from sched to libbuiltin/libgcc 2024-11-13 02:42:31 +08:00
irq sched/spin_lock: rename raw_spin_lock to spin_lock_notrace 2025-02-13 20:48:15 +08:00
misc Revert "No need to call sched_lock explicitly after call spin_lock_irqsave, since it will be called in func spin_lock_irqsave." 2025-02-13 14:15:43 +08:00
module libc/elf: rename modlib to libelf 2025-04-11 09:43:22 +08:00
mqueue sched/mqueue/CMakeLists.txt: fix compilation for CONFIG_DISABLE_MQUEUE_SYSV=n 2025-01-17 23:14:39 +08:00
paging Remove duplicate includes across multiple files 2025-01-09 23:30:23 +08:00
pthread sched/gettid: Move thread ID to TLS 2025-04-08 22:53:10 +08:00
sched sched/affinity: Fix CPU_LOCKED functionality for some SMP calls 2025-04-26 13:56:27 +08:00
semaphore libc/semaphore: Move fast mutex wait/post paths to libc 2025-04-01 20:37:23 +08:00
signal sched/signal/sig_dispatch: Fix race conditions between nxsig_tcbdispatch and nxsig_deliver 2025-05-02 09:21:14 -03:00
task sched/affinity: Fix CPU_LOCKED functionality for some SMP calls 2025-04-26 13:56:27 +08:00
timer sched/timer: remove critical section in setitimer 2025-01-19 17:08:32 +08:00
tls sched/gettid: Move thread ID to TLS 2025-04-08 22:53:10 +08:00
wdog sched/wdog: Fix int-to-pointer-cast and pointer-to-int-cast warnings. 2025-03-08 13:52:37 -03:00
wqueue sched/wqueue: Rename periodic workqueue API. 2025-03-08 13:52:37 -03:00
CMakeLists.txt sched: migrate to SPDX identifier 2024-09-12 01:10:14 +08:00
Kconfig libc/elf: rename modlib to libelf 2025-04-11 09:43:22 +08:00
Makefile Revert "build depend:Revert Make.dep intermediate ddc file" 2024-09-15 19:29:47 +08:00