Struct mycelium_kernel::rt::Core
source · pub struct Core {
scheduler: &'static StaticScheduler,
id: usize,
running: AtomicBool,
rng: Xoroshiro128PlusPlus,
}
Expand description
A kernel runtime for a single core.
Fields§
§scheduler: &'static StaticScheduler
The task scheduler for this core.
id: usize
This core’s ID.
ID 0 is the first CPU core started when the system boots.
running: AtomicBool
Set to false
if this core should shut down.
rng: Xoroshiro128PlusPlus
Used to select the index of the next core to steal work from.
Selecting a random core index when work-stealing helps ensure we don’t have a situation where all idle steal from the first available worker, resulting in other cores ending up with huge queues of idle tasks while the first core’s queue is always empty.
This is not a cryptographically secure random number generator, since randomness of this value is not required for security. Instead, it just helps ensure a good distribution of load. Therefore, we use a fast, non-cryptographic RNG.
Implementations§
source§impl Core
impl Core
pub fn new() -> Self
sourcepub fn tick(&mut self) -> bool
pub fn tick(&mut self) -> bool
Runs one tick of the kernel main loop on this core.
Returns true
if this core has more work to do, or false
if it does not.
sourcepub fn is_running(&self) -> bool
pub fn is_running(&self) -> bool
Returns true
if this core is currently running.
sourcepub fn stop(&self) -> bool
pub fn stop(&self) -> bool
Stops this core if it is currently running.
Returns
true
if this core was running and is now stoppingfalse
if this core was not running.
sourcepub fn run(&mut self)
pub fn run(&mut self)
Run this core until Core::stop
is called.
fn try_steal(&mut self) -> usize
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Core
impl Send for Core
impl Sync for Core
impl Unpin for Core
impl !UnwindSafe for Core
Blanket Implementations§
source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
. Read more§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read more§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read more§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s. Read more