Files
RedBear-OS/src/time.rs
T
2022-11-14 11:12:44 -07:00

17 lines
455 B
Rust

use spin::Mutex;
pub const NANOS_PER_SEC: u128 = 1_000_000_000;
/// Kernel start time, measured in (seconds, nanoseconds) since Unix epoch
pub static START: Mutex<u128> = Mutex::new(0);
/// Kernel up time, measured in (seconds, nanoseconds) since `START_TIME`
pub static OFFSET: Mutex<u128> = Mutex::new(0);
pub fn monotonic() -> u128 {
*OFFSET.lock() + crate::arch::time::counter()
}
pub fn realtime() -> u128 {
*START.lock() + monotonic()
}