mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 15:38:10 +00:00
Kernel: Fix signal delivery when no syscall is made
This fixes a regression introduced by the new software context switching where the Kernel would not deliver a signal unless the process is making system calls. This is because the TSS no longer updates the CS value, so the scheduler never considered delivery as the process always appeared to be in kernel mode. With software context switching we can just set up the signal trampoline at any time and when the processor returns back to user mode it'll get executed. This should fix e.g. killing programs that are stuck in some tight loop that doesn't make any system calls and is only pre-empted by the timer interrupt. Fixes #2958
This commit is contained in:
parent
6e54d0c072
commit
f011c420c1
4 changed files with 10 additions and 39 deletions
|
@ -405,17 +405,6 @@ bool Scheduler::pick_next()
|
|||
Thread::for_each_living([&](Thread& thread) -> IterationDecision {
|
||||
if (!thread.has_unmasked_pending_signals())
|
||||
return IterationDecision::Continue;
|
||||
// FIXME: It would be nice if the Scheduler didn't have to worry about who is "current"
|
||||
// For now, avoid dispatching signals to "current" and do it in a scheduling pass
|
||||
// while some other process is interrupted. Otherwise a mess will be made.
|
||||
if (&thread == current_thread)
|
||||
return IterationDecision::Continue;
|
||||
// We know how to interrupt blocked processes, but if they are just executing
|
||||
// at some random point in the kernel, let them continue.
|
||||
// Before returning to userspace from a syscall, we will block a thread if it has any
|
||||
// pending unmasked signals, allowing it to be dispatched then.
|
||||
if (thread.in_kernel() && !thread.is_blocked() && !thread.is_stopped())
|
||||
return IterationDecision::Continue;
|
||||
// NOTE: dispatch_one_pending_signal() may unblock the process.
|
||||
bool was_blocked = thread.is_blocked();
|
||||
if (thread.dispatch_one_pending_signal() == ShouldUnblockThread::No)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue