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