diff options
| author | diondokter <[email protected]> | 2025-08-29 14:36:17 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2025-09-11 14:45:27 +0200 |
| commit | 52d178560501a464dba67da89a1570ae9a2cf66c (patch) | |
| tree | 285b11fe4f91a77789f649377e431414e43f7ac2 /embassy-executor/src/raw/mod.rs | |
| parent | d6d4df1c768f8ae43ad1339b74d351f4cbad0386 (diff) | |
Introduce metadata-deadline and let the EDF scheduler use it
Diffstat (limited to 'embassy-executor/src/raw/mod.rs')
| -rw-r--r-- | embassy-executor/src/raw/mod.rs | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/embassy-executor/src/raw/mod.rs b/embassy-executor/src/raw/mod.rs index be2c5ee28..f93bfdef9 100644 --- a/embassy-executor/src/raw/mod.rs +++ b/embassy-executor/src/raw/mod.rs | |||
| @@ -26,7 +26,7 @@ pub(crate) mod util; | |||
| 26 | #[cfg_attr(feature = "turbowakers", path = "waker_turbo.rs")] | 26 | #[cfg_attr(feature = "turbowakers", path = "waker_turbo.rs")] |
| 27 | mod waker; | 27 | mod waker; |
| 28 | 28 | ||
| 29 | #[cfg(feature = "edf-scheduler")] | 29 | #[cfg(feature = "metadata-deadline")] |
| 30 | mod deadline; | 30 | mod deadline; |
| 31 | 31 | ||
| 32 | use core::future::Future; | 32 | use core::future::Future; |
| @@ -43,7 +43,7 @@ use embassy_executor_timer_queue::TimerQueueItem; | |||
| 43 | #[cfg(feature = "arch-avr")] | 43 | #[cfg(feature = "arch-avr")] |
| 44 | use portable_atomic::AtomicPtr; | 44 | use portable_atomic::AtomicPtr; |
| 45 | 45 | ||
| 46 | #[cfg(feature = "edf-scheduler")] | 46 | #[cfg(feature = "metadata-deadline")] |
| 47 | pub use deadline::Deadline; | 47 | pub use deadline::Deadline; |
| 48 | #[cfg(feature = "arch-avr")] | 48 | #[cfg(feature = "arch-avr")] |
| 49 | use portable_atomic::AtomicPtr; | 49 | use portable_atomic::AtomicPtr; |
| @@ -103,11 +103,6 @@ pub(crate) struct TaskHeader { | |||
| 103 | pub(crate) state: State, | 103 | pub(crate) state: State, |
| 104 | pub(crate) run_queue_item: RunQueueItem, | 104 | pub(crate) run_queue_item: RunQueueItem, |
| 105 | 105 | ||
| 106 | /// Earliest Deadline First scheduler Deadline. This field should not be accessed | ||
| 107 | /// outside the context of the task itself as it being polled by the executor. | ||
| 108 | #[cfg(feature = "edf-scheduler")] | ||
| 109 | pub(crate) deadline: Deadline, | ||
| 110 | |||
| 111 | pub(crate) executor: AtomicPtr<SyncExecutor>, | 106 | pub(crate) executor: AtomicPtr<SyncExecutor>, |
| 112 | poll_fn: SyncUnsafeCell<Option<unsafe fn(TaskRef)>>, | 107 | poll_fn: SyncUnsafeCell<Option<unsafe fn(TaskRef)>>, |
| 113 | 108 | ||
| @@ -212,10 +207,6 @@ impl<F: Future + 'static> TaskStorage<F> { | |||
| 212 | raw: TaskHeader { | 207 | raw: TaskHeader { |
| 213 | state: State::new(), | 208 | state: State::new(), |
| 214 | run_queue_item: RunQueueItem::new(), | 209 | run_queue_item: RunQueueItem::new(), |
| 215 | // NOTE: The deadline is set to zero to allow the initializer to reside in `.bss`. This | ||
| 216 | // will be lazily initalized in `initialize_impl` | ||
| 217 | #[cfg(feature = "edf-scheduler")] | ||
| 218 | deadline: Deadline::new_unset(), | ||
| 219 | executor: AtomicPtr::new(core::ptr::null_mut()), | 210 | executor: AtomicPtr::new(core::ptr::null_mut()), |
| 220 | // Note: this is lazily initialized so that a static `TaskStorage` will go in `.bss` | 211 | // Note: this is lazily initialized so that a static `TaskStorage` will go in `.bss` |
| 221 | poll_fn: SyncUnsafeCell::new(None), | 212 | poll_fn: SyncUnsafeCell::new(None), |
| @@ -315,7 +306,11 @@ impl<F: Future + 'static> AvailableTask<F> { | |||
| 315 | // By default, deadlines are set to the maximum value, so that any task WITH | 306 | // By default, deadlines are set to the maximum value, so that any task WITH |
| 316 | // a set deadline will ALWAYS be scheduled BEFORE a task WITHOUT a set deadline | 307 | // a set deadline will ALWAYS be scheduled BEFORE a task WITHOUT a set deadline |
| 317 | #[cfg(feature = "edf-scheduler")] | 308 | #[cfg(feature = "edf-scheduler")] |
| 318 | self.task.raw.deadline.set(deadline::Deadline::UNSET_DEADLINE_TICKS); | 309 | self.task |
| 310 | .raw | ||
| 311 | .metadata | ||
| 312 | .deadline() | ||
| 313 | .set(deadline::Deadline::UNSET_DEADLINE_TICKS); | ||
| 319 | 314 | ||
| 320 | let task = TaskRef::new(self.task); | 315 | let task = TaskRef::new(self.task); |
| 321 | 316 | ||
