mirror of
https://github.com/wichtounet/thor-os.git
synced 2025-09-17 08:37:17 -04:00
Allow the frequency to be changed
This commit is contained in:
parent
eb812462ba
commit
c273940e74
@ -64,6 +64,11 @@ void queue_system_process(pid_t pid);
|
||||
*/
|
||||
void queue_async_init_task(void (*fun)());
|
||||
|
||||
/*!
|
||||
* \brief Lets the scheduler know that the timer frequency has been updated
|
||||
*/
|
||||
void frequency_updated(uint64_t old_frequency, uint64_t new_frequency);
|
||||
|
||||
} //end of namespace scheduler
|
||||
|
||||
#endif
|
||||
|
@ -953,3 +953,16 @@ void scheduler::queue_system_process(scheduler::pid_t pid){
|
||||
void scheduler::queue_async_init_task(void (*fun)()){
|
||||
init_tasks.emplace_back(fun);
|
||||
}
|
||||
|
||||
void scheduler::frequency_updated(uint64_t old_frequency, uint64_t new_frequency){
|
||||
// Cannot be interrupted during frequency update
|
||||
direct_int_lock lock;
|
||||
|
||||
double ratio = old_frequency / double(new_frequency);
|
||||
|
||||
for(auto& process : pcb){
|
||||
if(process.state == process_state::SLEEPING){
|
||||
process.sleep_timeout *= ratio;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -75,7 +75,11 @@ uint64_t timer::frequency(){
|
||||
}
|
||||
|
||||
void timer::frequency(uint64_t freq){
|
||||
auto old_frequency = _timer_frequency;
|
||||
|
||||
_timer_frequency = freq;
|
||||
|
||||
logging::logf(logging::log_level::DEBUG, "timer: Frequency set to %u Hz\n", freq);
|
||||
|
||||
scheduler::frequency_updated(old_frequency, _timer_frequency);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user