blob: 6952e80ad81cac3f15917cd921ea9ad6c0e04f08 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
use std::ops::Range;
pub trait ECoreSelector {
fn next_core(&mut self) -> i32;
}
//TODO: better core selection e.g. try to keep task on the same core
pub struct RoundRobinSelector {
offset: u32,
num_cores: u32,
last_used: u32,
}
impl RoundRobinSelector {
pub fn new(e_cores: &Range<i32>) -> RoundRobinSelector {
Self {
offset: e_cores.start as u32,
num_cores: e_cores.len() as u32,
last_used: 0,
}
}
}
impl ECoreSelector for RoundRobinSelector {
// TODO: use task cpu if suitable
fn next_core(&mut self) -> i32 {
self.last_used += 1;
(self.offset + (self.last_used % self.num_cores)) as i32
}
}
|