diff options
| author | Dario Nieuwenhuis <[email protected]> | 2025-09-11 13:52:14 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-09-11 13:52:14 +0000 |
| commit | 42c68622eeba3be05e8f8ccdc4072b7aa57f78d1 (patch) | |
| tree | 431aa79f8343a7ed8eb948ad52dec5ef13f5869a /embassy-executor/src/raw/mod.rs | |
| parent | d860530009c1bf96a20edeff22f10f738bab1503 (diff) | |
| parent | e1209c5563576d18c4d033b015c9a5dd6145d581 (diff) | |
Merge pull request #4608 from diondokter/upstream-drs-2
[embassy-executor]: Upstream "Earliest Deadline First" Scheduler (version 2)
Diffstat (limited to 'embassy-executor/src/raw/mod.rs')
| -rw-r--r-- | embassy-executor/src/raw/mod.rs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/embassy-executor/src/raw/mod.rs b/embassy-executor/src/raw/mod.rs index 4280c5750..51a363385 100644 --- a/embassy-executor/src/raw/mod.rs +++ b/embassy-executor/src/raw/mod.rs | |||
| @@ -7,8 +7,6 @@ | |||
| 7 | //! Using this module requires respecting subtle safety contracts. If you can, prefer using the safe | 7 | //! Using this module requires respecting subtle safety contracts. If you can, prefer using the safe |
| 8 | //! [executor wrappers](crate::Executor) and the [`embassy_executor::task`](embassy_executor_macros::task) macro, which are fully safe. | 8 | //! [executor wrappers](crate::Executor) and the [`embassy_executor::task`](embassy_executor_macros::task) macro, which are fully safe. |
| 9 | 9 | ||
| 10 | #[cfg_attr(target_has_atomic = "ptr", path = "run_queue_atomics.rs")] | ||
| 11 | #[cfg_attr(not(target_has_atomic = "ptr"), path = "run_queue_critical_section.rs")] | ||
| 12 | mod run_queue; | 10 | mod run_queue; |
| 13 | 11 | ||
| 14 | #[cfg_attr(all(cortex_m, target_has_atomic = "32"), path = "state_atomics_arm.rs")] | 12 | #[cfg_attr(all(cortex_m, target_has_atomic = "32"), path = "state_atomics_arm.rs")] |
| @@ -28,6 +26,9 @@ pub(crate) mod util; | |||
| 28 | #[cfg_attr(feature = "turbowakers", path = "waker_turbo.rs")] | 26 | #[cfg_attr(feature = "turbowakers", path = "waker_turbo.rs")] |
| 29 | mod waker; | 27 | mod waker; |
| 30 | 28 | ||
| 29 | #[cfg(feature = "scheduler-deadline")] | ||
| 30 | mod deadline; | ||
| 31 | |||
| 31 | use core::future::Future; | 32 | use core::future::Future; |
| 32 | use core::marker::PhantomData; | 33 | use core::marker::PhantomData; |
| 33 | use core::mem; | 34 | use core::mem; |
| @@ -38,6 +39,8 @@ use core::sync::atomic::AtomicPtr; | |||
| 38 | use core::sync::atomic::Ordering; | 39 | use core::sync::atomic::Ordering; |
| 39 | use core::task::{Context, Poll, Waker}; | 40 | use core::task::{Context, Poll, Waker}; |
| 40 | 41 | ||
| 42 | #[cfg(feature = "scheduler-deadline")] | ||
| 43 | pub(crate) use deadline::Deadline; | ||
| 41 | use embassy_executor_timer_queue::TimerQueueItem; | 44 | use embassy_executor_timer_queue::TimerQueueItem; |
| 42 | #[cfg(feature = "arch-avr")] | 45 | #[cfg(feature = "arch-avr")] |
| 43 | use portable_atomic::AtomicPtr; | 46 | use portable_atomic::AtomicPtr; |
| @@ -96,6 +99,7 @@ extern "Rust" fn __embassy_time_queue_item_from_waker(waker: &Waker) -> &'static | |||
| 96 | pub(crate) struct TaskHeader { | 99 | pub(crate) struct TaskHeader { |
| 97 | pub(crate) state: State, | 100 | pub(crate) state: State, |
| 98 | pub(crate) run_queue_item: RunQueueItem, | 101 | pub(crate) run_queue_item: RunQueueItem, |
| 102 | |||
| 99 | pub(crate) executor: AtomicPtr<SyncExecutor>, | 103 | pub(crate) executor: AtomicPtr<SyncExecutor>, |
| 100 | poll_fn: SyncUnsafeCell<Option<unsafe fn(TaskRef)>>, | 104 | poll_fn: SyncUnsafeCell<Option<unsafe fn(TaskRef)>>, |
| 101 | 105 | ||
| @@ -296,6 +300,11 @@ impl<F: Future + 'static> AvailableTask<F> { | |||
| 296 | self.task.raw.poll_fn.set(Some(TaskStorage::<F>::poll)); | 300 | self.task.raw.poll_fn.set(Some(TaskStorage::<F>::poll)); |
| 297 | self.task.future.write_in_place(future); | 301 | self.task.future.write_in_place(future); |
| 298 | 302 | ||
| 303 | // By default, deadlines are set to the maximum value, so that any task WITH | ||
| 304 | // a set deadline will ALWAYS be scheduled BEFORE a task WITHOUT a set deadline | ||
| 305 | #[cfg(feature = "scheduler-deadline")] | ||
| 306 | self.task.raw.metadata.unset_deadline(); | ||
| 307 | |||
| 299 | let task = TaskRef::new(self.task); | 308 | let task = TaskRef::new(self.task); |
| 300 | 309 | ||
| 301 | SpawnToken::new(task) | 310 | SpawnToken::new(task) |
