summaryrefslogtreecommitdiff
path: root/Kernel/Arch/i386
diff options
context:
space:
mode:
authorTom <tomut@yahoo.com>2020-10-27 20:39:08 -0600
committerAndreas Kling <kling@serenityos.org>2020-11-11 12:27:25 +0100
commite26e0445b5b171afc33463f636fef24af858ae3b (patch)
tree09620d22c87ce3e6ccbb76c412e0eebe12887c41 /Kernel/Arch/i386
parenta14884dd33170b4e87ed566285def33f23953a7d (diff)
downloadserenity-e26e0445b5b171afc33463f636fef24af858ae3b.zip
Kernel: Make m_halt_requested an atomic variable
We need to make sure the change to this variable is visible to all processors instantly.
Diffstat (limited to 'Kernel/Arch/i386')
-rw-r--r--Kernel/Arch/i386/CPU.cpp8
-rw-r--r--Kernel/Arch/i386/CPU.h2
2 files changed, 5 insertions, 5 deletions
diff --git a/Kernel/Arch/i386/CPU.cpp b/Kernel/Arch/i386/CPU.cpp
index bb82d7fb5e..af1fa6e01e 100644
--- a/Kernel/Arch/i386/CPU.cpp
+++ b/Kernel/Arch/i386/CPU.cpp
@@ -1819,11 +1819,11 @@ bool Processor::smp_process_pending_messages()
}
}
- if (m_halt_requested)
+ if (m_halt_requested.load(AK::MemoryOrder::memory_order_relaxed))
halt_this();
}
did_process = true;
- } else if (m_halt_requested) {
+ } else if (m_halt_requested.load(AK::MemoryOrder::memory_order_relaxed)) {
halt_this();
}
@@ -1876,7 +1876,7 @@ void Processor::smp_broadcast_message(ProcessorMessage& msg, bool async)
// We need to check here if another processor may have requested
// us to halt before this message could be delivered. Otherwise
// we're just spinning the CPU because msg.refs will never drop to 0.
- if (cur_proc.m_halt_requested)
+ if (cur_proc.m_halt_requested.load(AK::MemoryOrder::memory_order_relaxed))
halt_this();
}
@@ -1918,7 +1918,7 @@ void Processor::smp_broadcast_halt()
// by being out of memory and we might not be able to get a message
for_each(
[&](Processor& proc) -> IterationDecision {
- proc.m_halt_requested = true;
+ proc.m_halt_requested.store(true, AK::MemoryOrder::memory_order_release);
return IterationDecision::Continue;
});
diff --git a/Kernel/Arch/i386/CPU.h b/Kernel/Arch/i386/CPU.h
index ab8d551b6c..2fbff06fd6 100644
--- a/Kernel/Arch/i386/CPU.h
+++ b/Kernel/Arch/i386/CPU.h
@@ -724,7 +724,7 @@ class Processor {
bool m_invoke_scheduler_async;
bool m_scheduler_initialized;
- bool m_halt_requested;
+ Atomic<bool> m_halt_requested;
DeferredCallEntry* m_pending_deferred_calls; // in reverse order
DeferredCallEntry* m_free_deferred_call_pool_entry;