mirror of
https://github.com/RGBCube/serenity
synced 2025-05-16 19:35:08 +00:00
Kernel: Use a separate timer for profiling the system
This updates the profiling subsystem to use a separate timer to trigger CPU sampling. This timer has a higher resolution (1000Hz) and is independent from the scheduler. At a later time the resolution could even be made configurable with an argument for sys$profiling_enable() - but not today.
This commit is contained in:
parent
d6b3513aab
commit
8614d18956
5 changed files with 46 additions and 8 deletions
|
@ -10,6 +10,7 @@
|
|||
#include <Kernel/ACPI/Parser.h>
|
||||
#include <Kernel/CommandLine.h>
|
||||
#include <Kernel/Interrupts/APIC.h>
|
||||
#include <Kernel/PerformanceManager.h>
|
||||
#include <Kernel/Scheduler.h>
|
||||
#include <Kernel/Time/APICTimer.h>
|
||||
#include <Kernel/Time/HPET.h>
|
||||
|
@ -289,6 +290,15 @@ UNMAP_AFTER_INIT bool TimeManagement::probe_and_set_non_legacy_hardware_timers()
|
|||
// We don't need an interrupt for time keeping purposes because we
|
||||
// can query the timer.
|
||||
m_time_keeper_timer = m_system_timer;
|
||||
|
||||
if (periodic_timers.size() > 1)
|
||||
m_profile_timer = periodic_timers[1];
|
||||
else
|
||||
m_profile_timer = non_periodic_timers[1];
|
||||
|
||||
m_profile_timer->set_callback(PerformanceManager::timer_tick);
|
||||
m_profile_timer->try_to_set_frequency(m_profile_timer->calculate_nearest_possible_frequency(1));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -379,4 +389,16 @@ void TimeManagement::system_timer_tick(const RegisterState& regs)
|
|||
Scheduler::timer_tick(regs);
|
||||
}
|
||||
|
||||
void TimeManagement::enable_profile_timer()
|
||||
{
|
||||
if (m_profile_enable_count.fetch_add(1) == 0)
|
||||
m_profile_timer->try_to_set_frequency(m_profile_timer->calculate_nearest_possible_frequency(OPTIMAL_PROFILE_TICKS_PER_SECOND_RATE));
|
||||
}
|
||||
|
||||
void TimeManagement::disable_profile_timer()
|
||||
{
|
||||
if (m_profile_enable_count.fetch_sub(1) == 1)
|
||||
m_profile_timer->try_to_set_frequency(m_profile_timer->calculate_nearest_possible_frequency(1));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue