RunQueue

Struct RunQueue 

Source
pub struct RunQueue<const N_QUEUES: usize, const N_THREADS: usize> { /* private fields */ }
Expand description

Runqueue for N_QUEUES, supporting N_THREADS total.

assumptions:

  • higher runqueue number means higher priority

  • runqueue numbers (corresponding priorities) are 0..N_QUEUES (exclusive)

  • runqueue numbers fit in usize bits (supporting max 32 priority levels)

  • pids range from 0..N_THREADS

  • N_THREADS is <255 (as u8 is used to store them, but 0xFF is used as special value)

    The current implementation needs an usize for the bit cache, an [u8; N_QUEUES] array for the list tail indexes and an [u8; N_THREADS] for the list next indexes.

Implementations§

Source§

impl<const N_QUEUES: usize, const N_THREADS: usize> RunQueue<N_QUEUES, N_THREADS>

Source

pub const fn new() -> RunQueue<N_QUEUES, N_THREADS>

Source

pub fn add(&mut self, n: ThreadId, rq: RunqueueId)

add thread with pid n to runqueue number rq

Source

pub fn del(&mut self, n: ThreadId, rq: RunqueueId)

remove thread with pid n from runqueue number rq @note: this implementation fails if “n” is not the queue’s head. This is fine, RIOT-rs only ever calls del() for the current thread.

Source

pub fn get_next(&self) -> Option<u8>

get pid that should run next returns the next runnable thread of the runqueue with the highest index

Source

pub fn advance(&mut self, rq: RunqueueId)

advance runqueue number rq (this is used to “yield” to another thread of the same priority)

Auto Trait Implementations§

§

impl<const N_QUEUES: usize, const N_THREADS: usize> Freeze for RunQueue<N_QUEUES, N_THREADS>

§

impl<const N_QUEUES: usize, const N_THREADS: usize> RefUnwindSafe for RunQueue<N_QUEUES, N_THREADS>

§

impl<const N_QUEUES: usize, const N_THREADS: usize> Send for RunQueue<N_QUEUES, N_THREADS>

§

impl<const N_QUEUES: usize, const N_THREADS: usize> Sync for RunQueue<N_QUEUES, N_THREADS>

§

impl<const N_QUEUES: usize, const N_THREADS: usize> Unpin for RunQueue<N_QUEUES, N_THREADS>

§

impl<const N_QUEUES: usize, const N_THREADS: usize> UnwindSafe for RunQueue<N_QUEUES, N_THREADS>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.