mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 01:20:25 +00:00
Kernel: Kill user mode threads that are marked to die
Threads that don't make syscalls still need to be killed, and we can do that at any time we want so long the thread is in user mode and not somehow blocked (e.g. page fault).
This commit is contained in:
parent
fa8fe40266
commit
b919789db2
Notes:
sideshowbarker
2024-07-19 01:59:31 +09:00
Author: https://github.com/tomuta Commit: https://github.com/SerenityOS/serenity/commit/b919789db24 Pull-request: https://github.com/SerenityOS/serenity/pull/8728 Reviewed-by: https://github.com/gunnarbeutner ✅
1 changed files with 10 additions and 0 deletions
|
@ -443,6 +443,16 @@ void Scheduler::timer_tick(const RegisterState& regs)
|
|||
return; // TODO: This prevents scheduling on other CPUs!
|
||||
#endif
|
||||
|
||||
if (current_thread->previous_mode() == Thread::PreviousMode::UserMode && current_thread->should_die() && !current_thread->is_blocked()) {
|
||||
dbgln_if(SCHEDULER_DEBUG, "Scheduler[{}]: Terminating user mode thread {}", Processor::id(), *current_thread);
|
||||
{
|
||||
ScopedSpinLock scheduler_lock(g_scheduler_lock);
|
||||
current_thread->set_state(Thread::Dying);
|
||||
}
|
||||
VERIFY(!Processor::current().in_critical());
|
||||
Processor::current().invoke_scheduler_async();
|
||||
return;
|
||||
}
|
||||
if (current_thread->tick())
|
||||
return;
|
||||
|
||||
|
|
Loading…
Reference in a new issue