mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 23:27:42 +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:
parent
5ada38f9c3
commit
806ade1367
2 changed files with 5 additions and 6 deletions
|
@ -667,8 +667,7 @@ void Thread::update_time_scheduled(u64 current_scheduler_time, bool is_kernel, b
|
|||
Scheduler::add_time_scheduled(delta, is_kernel);
|
||||
|
||||
auto& total_time = is_kernel ? m_total_time_scheduled_kernel : m_total_time_scheduled_user;
|
||||
SpinlockLocker scheduler_lock(g_scheduler_lock);
|
||||
total_time += delta;
|
||||
total_time.fetch_add(delta, AK::memory_order_relaxed);
|
||||
}
|
||||
}
|
||||
if (no_longer_running)
|
||||
|
|
|
@ -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 };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue