mirror of
https://github.com/hexagonal-sun/moss-kernel.git
synced 2026-01-30 17:11:47 -05:00
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:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user