xref: /DragonOS/kernel/src/time/tick_common.rs (revision af097f9f4b317337fe74aaa5070c34a14b8635fd)
1*af097f9fS黄铭涛 use crate::{
2*af097f9fS黄铭涛     arch::interrupt::TrapFrame,
3*af097f9fS黄铭涛     process::ProcessManager,
4*af097f9fS黄铭涛     smp::{core::smp_get_processor_id, cpu::ProcessorId},
5*af097f9fS黄铭涛     time::timer::run_local_timer,
6*af097f9fS黄铭涛 };
7*af097f9fS黄铭涛 
8*af097f9fS黄铭涛 use super::timer::update_timer_jiffies;
9*af097f9fS黄铭涛 
10*af097f9fS黄铭涛 /// # 函数的功能
11*af097f9fS黄铭涛 /// 用于周期滴答的事件处理
tick_handle_periodic(trap_frame: &TrapFrame)12*af097f9fS黄铭涛 pub fn tick_handle_periodic(trap_frame: &TrapFrame) {
13*af097f9fS黄铭涛     let cpu_id = smp_get_processor_id();
14*af097f9fS黄铭涛 
15*af097f9fS黄铭涛     tick_periodic(cpu_id, trap_frame);
16*af097f9fS黄铭涛 }
17*af097f9fS黄铭涛 
tick_periodic(cpu_id: ProcessorId, trap_frame: &TrapFrame)18*af097f9fS黄铭涛 fn tick_periodic(cpu_id: ProcessorId, trap_frame: &TrapFrame) {
19*af097f9fS黄铭涛     if cpu_id.data() == 0 {
20*af097f9fS黄铭涛         update_timer_jiffies(1);
21*af097f9fS黄铭涛         run_local_timer();
22*af097f9fS黄铭涛     }
23*af097f9fS黄铭涛 
24*af097f9fS黄铭涛     ProcessManager::update_process_times(trap_frame.is_from_user());
25*af097f9fS黄铭涛 }
26