forked from AbleOS/ableos
Compare commits
2 Commits
1d5bb220ec
...
88e324a8a9
Author | SHA1 | Date |
---|---|---|
MunirG05 | 88e324a8a9 | |
MunirG05 | e3f6295997 |
|
@ -7,9 +7,6 @@ use {crate::host::TrapHandler, hbvm::vm::Vm};
|
|||
|
||||
pub struct Scheduler<'a> {
|
||||
data: VecDeque<Vm<'a, TrapHandler>>,
|
||||
pub tick_callback: Option<fn() -> u64>,
|
||||
pub last_timer_count: u64,
|
||||
pub tick_limit: u64,
|
||||
}
|
||||
|
||||
// NOTE: This is a very simple schduler and it sucks and should be replaced with a better one
|
||||
|
@ -21,9 +18,7 @@ impl Scheduler<'_> {
|
|||
pub fn new() -> Self {
|
||||
Self {
|
||||
data: VecDeque::new(),
|
||||
tick_callback: None,
|
||||
last_timer_count: 0,
|
||||
tick_limit: 64,
|
||||
|
||||
}
|
||||
}
|
||||
pub fn new_process(&mut self, program: Vec<u8>) {
|
||||
|
@ -51,16 +46,6 @@ impl Scheduler<'_> {
|
|||
let mut prog = self.data.pop_front().unwrap();
|
||||
prog.run().unwrap();
|
||||
self.data.push_back(prog);
|
||||
if self.tick_callback.is_some() {
|
||||
let ret = self.tick_callback.unwrap()();
|
||||
if (ret - self.last_timer_count) >= self.tick_limit {
|
||||
|
||||
return Some(0);
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
Some(1)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue