ableos/ableos/src/time.rs

17 lines
380 B
Rust
Raw Normal View History

2022-07-31 06:54:01 +00:00
use crate::kmain::TICK;
2022-04-11 22:23:11 +00:00
use core::sync::atomic::Ordering;
2022-03-11 23:13:41 +00:00
#[cfg(target_arch = "x86_64")]
pub fn fetch_time() -> f64 {
2022-07-29 11:13:26 +00:00
let time = x86_64::instructions::interrupts::without_interrupts(|| {
TICK.load(Ordering::Relaxed) as f64
});
2022-03-11 23:13:41 +00:00
time
}
#[cfg(target_arch = "riscv64")]
pub fn fetch_time() -> f64 {
let time = TICK.load(Ordering::Relaxed) as f64;
time
}