diff options
author | Daniel Bertalan <dani@danielbertalan.dev> | 2021-06-24 10:03:07 +0200 |
---|---|---|
committer | Ali Mohammad Pur <Ali.mpfard@gmail.com> | 2021-06-24 17:35:49 +0430 |
commit | 74535628a88a575b433b82ce6dcb54c7875febf4 (patch) | |
tree | 9bcf909e600e3f55d38f30d9673a86e590789ec7 /Kernel/Arch/x86/Processor.h | |
parent | f28f00c654c44a2762cb4a702a9ad9377cdadf3b (diff) | |
download | serenity-74535628a88a575b433b82ce6dcb54c7875febf4.zip |
Kernel: Use proper `Atomic<T>` types in CPU
This is needed because Clang's intrinsic atomic functions behave weirdly
if only one of their pointer arguments is volatile.
Diffstat (limited to 'Kernel/Arch/x86/Processor.h')
-rw-r--r-- | Kernel/Arch/x86/Processor.h | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/Kernel/Arch/x86/Processor.h b/Kernel/Arch/x86/Processor.h index 5488556d4a..5565d9c81f 100644 --- a/Kernel/Arch/x86/Processor.h +++ b/Kernel/Arch/x86/Processor.h @@ -40,7 +40,7 @@ struct ProcessorMessage { Callback, }; Type type; - volatile u32 refs; // atomic + Atomic<u32> refs; union { ProcessorMessage* next; // only valid while in the pool alignas(CallbackFunction) u8 callback_storage[sizeof(CallbackFunction)]; @@ -115,7 +115,7 @@ class Processor { TSS m_tss; static FPUState s_clean_fpu_state; CPUFeature m_features; - static volatile u32 g_total_processors; // atomic + static Atomic<u32> g_total_processors; u8 m_physical_address_bit_width; ProcessorInfo* m_info; @@ -124,7 +124,7 @@ class Processor { Thread* m_current_thread; Thread* m_idle_thread; - volatile ProcessorMessageEntry* m_message_queue; // atomic, LIFO + Atomic<ProcessorMessageEntry*> m_message_queue; bool m_invoke_scheduler_async; bool m_scheduler_initialized; @@ -178,8 +178,8 @@ public: static u32 count() { // NOTE: because this value never changes once all APs are booted, - // we don't really need to do an atomic_load() on this variable - return g_total_processors; + // we can safely bypass loading it atomically. + return *g_total_processors.ptr(); } ALWAYS_INLINE static void wait_check() |