Kernel: Replace HPET CriticalScope with SpinLock
This commit is contained in:
parent
18253b6966
commit
682de62c57
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <kernel/InterruptController.h>
|
||||
#include <kernel/Lock/SpinLock.h>
|
||||
#include <kernel/Timer/Timer.h>
|
||||
|
||||
namespace Kernel
|
||||
|
@ -30,6 +31,8 @@ namespace Kernel
|
|||
uint64_t read_main_counter() const;
|
||||
|
||||
private:
|
||||
mutable SpinLock m_lock;
|
||||
|
||||
bool m_is_64bit { false };
|
||||
|
||||
uint64_t m_last_ticks { 0 };
|
||||
|
|
|
@ -244,7 +244,7 @@ namespace Kernel
|
|||
if (m_is_64bit)
|
||||
return regs.main_counter.full;
|
||||
|
||||
CriticalScope _;
|
||||
SpinLockGuard _(m_lock);
|
||||
uint32_t current_low = regs.main_counter.low;
|
||||
uint32_t wraps = m_32bit_wraps;
|
||||
if (current_low < (uint32_t)m_last_ticks)
|
||||
|
@ -256,8 +256,10 @@ namespace Kernel
|
|||
{
|
||||
auto& regs = registers();
|
||||
|
||||
uint64_t current_ticks;
|
||||
{
|
||||
SpinLockGuard _(m_lock);
|
||||
|
||||
uint64_t current_ticks;
|
||||
if (m_is_64bit)
|
||||
current_ticks = regs.main_counter.full;
|
||||
else
|
||||
|
@ -267,8 +269,8 @@ namespace Kernel
|
|||
m_32bit_wraps++;
|
||||
current_ticks = ((uint64_t)m_32bit_wraps << 32) | current_low;
|
||||
}
|
||||
|
||||
m_last_ticks = current_ticks;
|
||||
}
|
||||
|
||||
Scheduler::get().timer_reschedule();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue