summaryrefslogtreecommitdiff
path: root/Kernel/Thread.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-08-10 01:56:21 +0200
committerAndreas Kling <kling@serenityos.org>2021-08-10 02:49:37 +0200
commit0a02496f04d3a83ec0eb65635d39dff0b3fd4304 (patch)
tree8ba98568abfd18706bb6f17e3d96c150a448deb1 /Kernel/Thread.cpp
parent364134ad4b3ac20111bad18f39baf8c458f9c5b7 (diff)
downloadserenity-0a02496f04d3a83ec0eb65635d39dff0b3fd4304.zip
Kernel/SMP: Change critical sections to not disable interrupts
Leave interrupts enabled so that we can still process IRQs. Critical sections should only prevent preemption by another thread. Co-authored-by: Tom <tomut@yahoo.com>
Diffstat (limited to 'Kernel/Thread.cpp')
-rw-r--r--Kernel/Thread.cpp13
1 files changed, 5 insertions, 8 deletions
diff --git a/Kernel/Thread.cpp b/Kernel/Thread.cpp
index 71313e8774..4a72194090 100644
--- a/Kernel/Thread.cpp
+++ b/Kernel/Thread.cpp
@@ -388,8 +388,7 @@ void Thread::die_if_needed()
// Now leave the critical section so that we can also trigger the
// actual context switch
- u32 prev_flags;
- Processor::clear_critical(prev_flags, false);
+ Processor::clear_critical();
dbgln("die_if_needed returned from clear_critical!!! in irq: {}", Processor::current().in_irq());
// We should never get here, but the scoped scheduler lock
// will be released by Scheduler::context_switch again
@@ -420,10 +419,9 @@ void Thread::yield_assuming_not_holding_big_lock()
// Disable interrupts here. This ensures we don't accidentally switch contexts twice
InterruptDisabler disable;
Scheduler::yield(); // flag a switch
- u32 prev_flags;
- u32 prev_crit = Processor::clear_critical(prev_flags, true);
+ u32 prev_critical = Processor::clear_critical();
// NOTE: We may be on a different CPU now!
- Processor::restore_critical(prev_crit, prev_flags);
+ Processor::restore_critical(prev_critical);
}
void Thread::yield_and_release_relock_big_lock()
@@ -451,13 +449,12 @@ void Thread::relock_process(LockMode previous_locked, u32 lock_count_to_restore)
// flagged by calling Scheduler::yield above.
// We have to do it this way because we intentionally
// leave the critical section here to be able to switch contexts.
- u32 prev_flags;
- u32 prev_crit = Processor::clear_critical(prev_flags, true);
+ u32 prev_critical = Processor::clear_critical();
// CONTEXT SWITCH HAPPENS HERE!
// NOTE: We may be on a different CPU now!
- Processor::restore_critical(prev_crit, prev_flags);
+ Processor::restore_critical(prev_critical);
if (previous_locked != LockMode::Unlocked) {
// We've unblocked, relock the process if needed and carry on.