Time (#11)
* WIP: Time syscalls * Count time from PIT using low tickrate * Implement realtime * Implement nanosleep with a tight loop
This commit is contained in:
parent
798f7c8808
commit
64cc730eac
1 changed files with 199 additions and 7 deletions
15
arch/x86_64/src/time.rs
Normal file
15
arch/x86_64/src/time.rs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
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)
|
||||
}
|
||||
Loading…
Reference in a new issue