Change time offset to RwLock
This commit is contained in:
@@ -128,7 +128,7 @@ impl InterruptHandler for GenericTimer {
|
|||||||
fn irq_handler(&mut self, irq: u32, token: &mut CleanLockToken) {
|
fn irq_handler(&mut self, irq: u32, token: &mut CleanLockToken) {
|
||||||
self.clear_irq();
|
self.clear_irq();
|
||||||
{
|
{
|
||||||
*time::OFFSET.lock(token.token()) += self.clk_freq as u128;
|
*time::OFFSET.write(token.token()) += self.clk_freq as u128;
|
||||||
}
|
}
|
||||||
|
|
||||||
timeout::trigger(token);
|
timeout::trigger(token);
|
||||||
|
|||||||
@@ -169,7 +169,7 @@ interrupt_stack!(pit_stack, |_stack| {
|
|||||||
|
|
||||||
let mut token = unsafe { CleanLockToken::new() };
|
let mut token = unsafe { CleanLockToken::new() };
|
||||||
{
|
{
|
||||||
*time::OFFSET.lock(token.token()) += pit::RATE;
|
*time::OFFSET.write(token.token()) += pit::RATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe { eoi(0) };
|
unsafe { eoi(0) };
|
||||||
|
|||||||
@@ -12,7 +12,8 @@ pub fn monotonic_absolute(token: &mut CleanLockToken) -> u128 {
|
|||||||
return ns;
|
return ns;
|
||||||
}
|
}
|
||||||
|
|
||||||
*crate::time::OFFSET.lock(token.token()) + hpet_or_pit()
|
let offset = { *crate::time::OFFSET.read(token.token()) };
|
||||||
|
offset + hpet_or_pit()
|
||||||
}
|
}
|
||||||
fn hpet_or_pit() -> u128 {
|
fn hpet_or_pit() -> u128 {
|
||||||
#[cfg(feature = "acpi")]
|
#[cfg(feature = "acpi")]
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
sync::{CleanLockToken, Mutex, L1},
|
sync::{CleanLockToken, Mutex, RwLock, L1},
|
||||||
syscall::error::{Error, Result, EINVAL},
|
syscall::error::{Error, Result, EINVAL},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -9,7 +9,7 @@ pub const NANOS_PER_SEC: u128 = 1_000_000_000;
|
|||||||
/// Kernel start time, measured in nanoseconds since Unix epoch
|
/// Kernel start time, measured in nanoseconds since Unix epoch
|
||||||
pub static START: Mutex<L1, u128> = Mutex::new(0);
|
pub static START: Mutex<L1, u128> = Mutex::new(0);
|
||||||
/// Kernel up time, measured in nanoseconds since `START_TIME`
|
/// Kernel up time, measured in nanoseconds since `START_TIME`
|
||||||
pub static OFFSET: Mutex<L1, u128> = Mutex::new(0);
|
pub static OFFSET: RwLock<L1, u128> = RwLock::new(0);
|
||||||
|
|
||||||
pub fn monotonic(token: &mut CleanLockToken) -> u128 {
|
pub fn monotonic(token: &mut CleanLockToken) -> u128 {
|
||||||
crate::arch::time::monotonic_absolute(token)
|
crate::arch::time::monotonic_absolute(token)
|
||||||
|
|||||||
Reference in New Issue
Block a user