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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//! Earliest-Deadline-First (EDF) dequeue policy.
//!
//! Implements [`DequeuePolicy`](limen_core::scheduling::DequeuePolicy).
//! Among `Ready` candidates it selects the node with the smallest
//! `earliest_deadline`. Ties are broken by round-robin. If no `Ready` node
//! has a deadline, falls back to any `Ready` candidate in round-robin order.
//!
//! > **Status: stub.** Implementation is sketched in commented code; pending
//! > `RS1` runtime lifecycle work for activation.
// use limen_core::scheduling::{DequeuePolicy, NodeSummary, Readiness};
// use limen_core::types::NodeIndex;
// /// EDF policy that prioritizes nodes with the earliest absolute deadline.
// #[derive(Debug, Default)]
// pub struct EdfPolicy {
// rr: usize,
// }
// impl DequeuePolicy for EdfPolicy {
// fn select_next(&mut self, candidates: &[NodeSummary]) -> Option<NodeIndex> {
// // Prefer Ready nodes with a deadline, pick the smallest deadline.
// let mut best: Option<(usize, u64, usize)> = None; // (idx_in_slice, deadline_ns, rr_tie)
// for (i, c) in candidates.iter().enumerate() {
// if c.readiness != Readiness::Ready {
// continue;
// }
// if let Some(d) = c.earliest_deadline {
// let d_ns = d.0;
// let tie = (self.rr + i) % (candidates.len().max(1));
// match best {
// None => best = Some((i, d_ns, tie)),
// Some((_, bd, bt)) => {
// if d_ns < bd || (d_ns == bd && tie < bt) {
// best = Some((i, d_ns, tie));
// }
// }
// }
// }
// }
// self.rr = self.rr.wrapping_add(1);
// best.map(|(i, _, _)| candidates[i].index).or_else(|| {
// // Fallback: any Ready candidate
// candidates
// .iter()
// .position(|c| c.readiness == Readiness::Ready)
// .map(|i| candidates[i].index)
// })
// }
// }