mirror of
https://gitlab.redox-os.org/redox-os/redox.git
synced 2026-06-28 23:58:42 +08:00
* WIP: Time syscalls * Count time from PIT using low tickrate * Implement realtime * Implement nanosleep with a tight loop
16 lines
386 B
Rust
16 lines
386 B
Rust
use spin::Mutex;
|
|
|
|
pub static START: Mutex<(u64, u64)> = Mutex::new((0, 0));
|
|
pub static OFFSET: Mutex<(u64, u64)> = Mutex::new((0, 0));
|
|
|
|
pub fn monotonic() -> (u64, u64) {
|
|
*OFFSET.lock()
|
|
}
|
|
|
|
pub fn realtime() -> (u64, u64) {
|
|
let offset = monotonic();
|
|
let start = *START.lock();
|
|
let sum = start.1 + offset.1;
|
|
(start.0 + offset.0 + sum / 1000000000, sum % 1000000000)
|
|
}
|