1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:07:35 +00:00

Kernel: Don't lock scheduler while updating thread scheduling times

We can use simple atomic variables with relaxed ordering for this,
and avoid locking altogether.
This commit is contained in:
Andreas Kling 2022-08-19 13:54:14 +02:00
parent 5ada38f9c3
commit 806ade1367
2 changed files with 5 additions and 6 deletions

View file

@ -1062,8 +1062,8 @@ public:
static constexpr u32 default_kernel_stack_size = 65536;
static constexpr u32 default_userspace_stack_size = 1 * MiB;
u64 time_in_user() const { return m_total_time_scheduled_user; }
u64 time_in_kernel() const { return m_total_time_scheduled_kernel; }
u64 time_in_user() const { return m_total_time_scheduled_user.load(AK::MemoryOrder::memory_order_relaxed); }
u64 time_in_kernel() const { return m_total_time_scheduled_kernel.load(AK::MemoryOrder::memory_order_relaxed); }
enum class PreviousMode : u8 {
KernelMode = 0,
@ -1238,8 +1238,8 @@ private:
Atomic<u32> m_cpu { 0 };
u32 m_cpu_affinity { THREAD_AFFINITY_DEFAULT };
Optional<u64> m_last_time_scheduled;
u64 m_total_time_scheduled_user { 0 };
u64 m_total_time_scheduled_kernel { 0 };
Atomic<u64> m_total_time_scheduled_user { 0 };
Atomic<u64> m_total_time_scheduled_kernel { 0 };
u32 m_ticks_left { 0 };
u32 m_times_scheduled { 0 };
u32 m_ticks_in_user { 0 };