diff options
Diffstat (limited to 'embassy-executor/src/raw')
| -rw-r--r-- | embassy-executor/src/raw/deadline.rs | 14 | ||||
| -rw-r--r-- | embassy-executor/src/raw/mod.rs | 8 | ||||
| -rw-r--r-- | embassy-executor/src/raw/run_queue.rs | 8 |
3 files changed, 8 insertions, 22 deletions
diff --git a/embassy-executor/src/raw/deadline.rs b/embassy-executor/src/raw/deadline.rs index f6d016ae7..cc89fadb0 100644 --- a/embassy-executor/src/raw/deadline.rs +++ b/embassy-executor/src/raw/deadline.rs | |||
| @@ -7,7 +7,7 @@ use core::sync::atomic::{AtomicU32, Ordering}; | |||
| 7 | /// Note: Interacting with the deadline should be done locally in a task. | 7 | /// Note: Interacting with the deadline should be done locally in a task. |
| 8 | /// In theory you could try to set or read the deadline from another task, | 8 | /// In theory you could try to set or read the deadline from another task, |
| 9 | /// but that will result in weird (though not unsound) behavior. | 9 | /// but that will result in weird (though not unsound) behavior. |
| 10 | pub struct Deadline { | 10 | pub(crate) struct Deadline { |
| 11 | instant_ticks_hi: AtomicU32, | 11 | instant_ticks_hi: AtomicU32, |
| 12 | instant_ticks_lo: AtomicU32, | 12 | instant_ticks_lo: AtomicU32, |
| 13 | } | 13 | } |
| @@ -21,7 +21,7 @@ impl Deadline { | |||
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | pub(crate) const fn new_unset() -> Self { | 23 | pub(crate) const fn new_unset() -> Self { |
| 24 | Self::new(Self::UNSET_DEADLINE_TICKS) | 24 | Self::new(Self::UNSET_TICKS) |
| 25 | } | 25 | } |
| 26 | 26 | ||
| 27 | pub(crate) fn set(&self, instant_ticks: u64) { | 27 | pub(crate) fn set(&self, instant_ticks: u64) { |
| @@ -31,7 +31,7 @@ impl Deadline { | |||
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | /// Deadline value in ticks, same time base and ticks as `embassy-time` | 33 | /// Deadline value in ticks, same time base and ticks as `embassy-time` |
| 34 | pub fn instant_ticks(&self) -> u64 { | 34 | pub(crate) fn instant_ticks(&self) -> u64 { |
| 35 | let hi = self.instant_ticks_hi.load(Ordering::Relaxed) as u64; | 35 | let hi = self.instant_ticks_hi.load(Ordering::Relaxed) as u64; |
| 36 | let lo = self.instant_ticks_lo.load(Ordering::Relaxed) as u64; | 36 | let lo = self.instant_ticks_lo.load(Ordering::Relaxed) as u64; |
| 37 | 37 | ||
| @@ -40,11 +40,5 @@ impl Deadline { | |||
| 40 | 40 | ||
| 41 | /// Sentinel value representing an "unset" deadline, which has lower priority | 41 | /// Sentinel value representing an "unset" deadline, which has lower priority |
| 42 | /// than any other set deadline value | 42 | /// than any other set deadline value |
| 43 | pub const UNSET_DEADLINE_TICKS: u64 = u64::MAX; | 43 | pub(crate) const UNSET_TICKS: u64 = u64::MAX; |
| 44 | |||
| 45 | /// Does the given Deadline represent an "unset" deadline? | ||
| 46 | #[inline] | ||
| 47 | pub fn is_unset(&self) -> bool { | ||
| 48 | self.instant_ticks() == Self::UNSET_DEADLINE_TICKS | ||
| 49 | } | ||
| 50 | } | 44 | } |
diff --git a/embassy-executor/src/raw/mod.rs b/embassy-executor/src/raw/mod.rs index 6a9dd9749..51a363385 100644 --- a/embassy-executor/src/raw/mod.rs +++ b/embassy-executor/src/raw/mod.rs | |||
| @@ -40,7 +40,7 @@ use core::sync::atomic::Ordering; | |||
| 40 | use core::task::{Context, Poll, Waker}; | 40 | use core::task::{Context, Poll, Waker}; |
| 41 | 41 | ||
| 42 | #[cfg(feature = "scheduler-deadline")] | 42 | #[cfg(feature = "scheduler-deadline")] |
| 43 | pub use deadline::Deadline; | 43 | pub(crate) use deadline::Deadline; |
| 44 | use embassy_executor_timer_queue::TimerQueueItem; | 44 | use embassy_executor_timer_queue::TimerQueueItem; |
| 45 | #[cfg(feature = "arch-avr")] | 45 | #[cfg(feature = "arch-avr")] |
| 46 | use portable_atomic::AtomicPtr; | 46 | use portable_atomic::AtomicPtr; |
| @@ -303,11 +303,7 @@ impl<F: Future + 'static> AvailableTask<F> { | |||
| 303 | // By default, deadlines are set to the maximum value, so that any task WITH | 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 | 304 | // a set deadline will ALWAYS be scheduled BEFORE a task WITHOUT a set deadline |
| 305 | #[cfg(feature = "scheduler-deadline")] | 305 | #[cfg(feature = "scheduler-deadline")] |
| 306 | self.task | 306 | self.task.raw.metadata.unset_deadline(); |
| 307 | .raw | ||
| 308 | .metadata | ||
| 309 | .deadline() | ||
| 310 | .set(deadline::Deadline::UNSET_DEADLINE_TICKS); | ||
| 311 | 307 | ||
| 312 | let task = TaskRef::new(self.task); | 308 | let task = TaskRef::new(self.task); |
| 313 | 309 | ||
diff --git a/embassy-executor/src/raw/run_queue.rs b/embassy-executor/src/raw/run_queue.rs index 29c977226..d98c26f73 100644 --- a/embassy-executor/src/raw/run_queue.rs +++ b/embassy-executor/src/raw/run_queue.rs | |||
| @@ -108,12 +108,8 @@ impl RunQueue { | |||
| 108 | /// runqueue are both empty, at which point this function will return. | 108 | /// runqueue are both empty, at which point this function will return. |
| 109 | #[cfg(feature = "scheduler-deadline")] | 109 | #[cfg(feature = "scheduler-deadline")] |
| 110 | pub(crate) fn dequeue_all(&self, on_task: impl Fn(TaskRef)) { | 110 | pub(crate) fn dequeue_all(&self, on_task: impl Fn(TaskRef)) { |
| 111 | let mut sorted = SortedList::<TaskHeader>::new_with_cmp(|lhs, rhs| { | 111 | let mut sorted = |
| 112 | lhs.metadata | 112 | SortedList::<TaskHeader>::new_with_cmp(|lhs, rhs| lhs.metadata.deadline().cmp(&rhs.metadata.deadline())); |
| 113 | .deadline() | ||
| 114 | .instant_ticks() | ||
| 115 | .cmp(&rhs.metadata.deadline().instant_ticks()) | ||
| 116 | }); | ||
| 117 | 113 | ||
| 118 | loop { | 114 | loop { |
| 119 | // For each loop, grab any newly pended items | 115 | // For each loop, grab any newly pended items |
