thread_group: deliver_signal: ensure signal delivery

If all tasks within a thread group are sleeping when a signal is
delivered, wake at least one task to action the signal.
This commit is contained in:
Matthew Leach
2026-01-15 22:41:46 +00:00
parent 798cad0c38
commit 71d120ebe7
2 changed files with 24 additions and 1 deletions

View File

@@ -176,6 +176,29 @@ impl ThreadGroup {
}
_ => {
self.pending_signals.lock_save_irq().set_signal(signal);
// See whether there is a task that can action the signal.
for task in self.tasks.lock_save_irq().values() {
if let Some(task) = task.upgrade()
&& matches!(
*task.state.lock_save_irq(),
TaskState::Runnable | TaskState::Running
)
{
// Signal delivered. This task will eventually be
// dispatched again by the uspc_ret code and the
// signal picked up.
return;
}
}
// No task will pick up the signal. Wake one up.
for task in self.tasks.lock_save_irq().values() {
if let Some(task) = task.upgrade() {
create_waker(task.descriptor()).wake();
return;
}
}
}
}
}

View File

@@ -99,7 +99,7 @@ pub fn send_signal_to_pg(pgid: Pgid, signal: SigId) {
if let Some(tg) = tg_weak.upgrade()
&& *tg.pgid.lock_save_irq() == pgid
{
tg.pending_signals.lock_save_irq().set_signal(signal);
tg.deliver_signal(signal);
}
}
}