|
|
|
@ -12,7 +12,7 @@ use nudge::{likely}; |
|
|
|
|
use crate::asm::instr::cond::Flag; |
|
|
|
|
use std::fmt::{Debug, Formatter}; |
|
|
|
|
use std::fmt; |
|
|
|
|
use std::time::Instant; |
|
|
|
|
use std::time::{Instant, Duration}; |
|
|
|
|
|
|
|
|
|
pub struct RunState { |
|
|
|
|
pub thread_info: Arc<ThreadInfo>, |
|
|
|
@ -95,10 +95,24 @@ impl RunState { |
|
|
|
|
}); |
|
|
|
|
if self.cr_deadline.is_none() { |
|
|
|
|
// start context switching
|
|
|
|
|
self.cr_deadline = Some(Instant::now() + *self.thread_info.scheduler_interval.read()); |
|
|
|
|
self.start_task_switching(); |
|
|
|
|
} |
|
|
|
|
handle |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
pub(crate) fn start_task_switching(&mut self) { |
|
|
|
|
let ival = *self.thread_info.scheduler_interval.read(); |
|
|
|
|
if ival > Duration::default() { |
|
|
|
|
self.cr_deadline = Some(Instant::now() + ival); |
|
|
|
|
} else { |
|
|
|
|
// Disabled
|
|
|
|
|
self.cr_deadline = None; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
pub(crate) fn stop_task_switching(&mut self) { |
|
|
|
|
self.cr_deadline = None; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
impl Debug for RunState { |
|
|
|
|