diff options
| author | James Munns <[email protected]> | 2025-03-20 14:32:14 +0100 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2025-09-11 14:45:06 +0200 |
| commit | 1f50e4d496458dbc7fccd9d028217ebfa7735471 (patch) | |
| tree | 5e8824fa0dc9e39287dc7a3f28df8161ddee1aa2 /embassy-executor/src/raw/mod.rs | |
| parent | 535c80e61f17e4ee4605e00623aabeda2181352d (diff) | |
Implement Deadline Ranked Scheduling
This implements a minimal version of Deadline Rank Scheduling, as well as ways to access and set Deadlines.
This still needs some UX improvements, but is likely Enough for testing.
Diffstat (limited to 'embassy-executor/src/raw/mod.rs')
| -rw-r--r-- | embassy-executor/src/raw/mod.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/embassy-executor/src/raw/mod.rs b/embassy-executor/src/raw/mod.rs index 894a996ec..9b8a4ea8a 100644 --- a/embassy-executor/src/raw/mod.rs +++ b/embassy-executor/src/raw/mod.rs | |||
| @@ -68,6 +68,9 @@ extern "Rust" fn __embassy_time_queue_item_from_waker(waker: &Waker) -> &'static | |||
| 68 | #[cfg(feature = "drs-scheduler")] | 68 | #[cfg(feature = "drs-scheduler")] |
| 69 | use cordyceps::{stack, Linked}; | 69 | use cordyceps::{stack, Linked}; |
| 70 | 70 | ||
| 71 | #[cfg(feature = "drs-scheduler")] | ||
| 72 | pub use run_queue::Deadline; | ||
| 73 | |||
| 71 | /// Raw task header for use in task pointers. | 74 | /// Raw task header for use in task pointers. |
| 72 | /// | 75 | /// |
| 73 | /// A task can be in one of the following states: | 76 | /// A task can be in one of the following states: |
| @@ -124,6 +127,9 @@ pub(crate) struct TaskHeader { | |||
| 124 | #[cfg(feature = "drs-scheduler")] | 127 | #[cfg(feature = "drs-scheduler")] |
| 125 | pub(crate) links: stack::Links<TaskHeader>, | 128 | pub(crate) links: stack::Links<TaskHeader>, |
| 126 | 129 | ||
| 130 | #[cfg(feature = "drs-scheduler")] | ||
| 131 | pub(crate) deadline: SyncUnsafeCell<u64>, | ||
| 132 | |||
| 127 | // TODO(AJM): We could potentially replace RunQueueItem for other runqueue impls, though | 133 | // TODO(AJM): We could potentially replace RunQueueItem for other runqueue impls, though |
| 128 | // right now cordyceps doesn't work on non-atomic systems | 134 | // right now cordyceps doesn't work on non-atomic systems |
| 129 | #[cfg(not(feature = "drs-scheduler"))] | 135 | #[cfg(not(feature = "drs-scheduler"))] |
| @@ -255,6 +261,8 @@ impl<F: Future + 'static> TaskStorage<F> { | |||
| 255 | run_queue_item: RunQueueItem::new(), | 261 | run_queue_item: RunQueueItem::new(), |
| 256 | #[cfg(feature = "drs-scheduler")] | 262 | #[cfg(feature = "drs-scheduler")] |
| 257 | links: stack::Links::new(), | 263 | links: stack::Links::new(), |
| 264 | #[cfg(feature = "drs-scheduler")] | ||
| 265 | deadline: SyncUnsafeCell::new(0u64), | ||
| 258 | state: State::new(), | 266 | state: State::new(), |
| 259 | executor: AtomicPtr::new(core::ptr::null_mut()), | 267 | executor: AtomicPtr::new(core::ptr::null_mut()), |
| 260 | // Note: this is lazily initialized so that a static `TaskStorage` will go in `.bss` | 268 | // Note: this is lazily initialized so that a static `TaskStorage` will go in `.bss` |
| @@ -352,6 +360,10 @@ impl<F: Future + 'static> AvailableTask<F> { | |||
| 352 | self.task.raw.poll_fn.set(Some(TaskStorage::<F>::poll)); | 360 | self.task.raw.poll_fn.set(Some(TaskStorage::<F>::poll)); |
| 353 | self.task.future.write_in_place(future); | 361 | self.task.future.write_in_place(future); |
| 354 | 362 | ||
| 363 | // TODO(AJM): Some other way of setting this? Just a placeholder | ||
| 364 | #[cfg(feature = "drs-scheduler")] | ||
| 365 | self.task.raw.deadline.set(u64::MAX); | ||
| 366 | |||
| 355 | let task = TaskRef::new(self.task); | 367 | let task = TaskRef::new(self.task); |
| 356 | 368 | ||
| 357 | SpawnToken::new(task) | 369 | SpawnToken::new(task) |
