Expand description
Kernel Scheduler / Context Switching engine
The module provides several interfaces for managing context switches. Each is different in its contract:
block()is used when a thread is taken out of the scheduler algorithm and is managed by another source such as a wait queue. These threads should be in theState::WaitingInterruptibleorState::WaitingNonInterruptiblestate.try_reschedule()is used when there is a change to the scheduling state (such as waking a thread). Depending on the local threadβsPreemptDisableGuardstate and the scheduler state, this may trigger an immediate context switch or it may defer it. This is useful for code which may or may not be called in an interrupt context.try_deferred_reschedule()is used to trigger a context switch if one was deferred bytry_reschedule(). Notably, this does not guarantee a context switch if thePreemptDisableGuardstate is not active but does guarantee forward progress. This comes into play for architectures like M-profile ARM which handles the context switch in an exception handler after an interrupt has returned.
Re-exportsΒ§
pub(crate) use core::block;πpub use core::JoinResult;pub use core::PreemptDisableGuard;pub use core::ProcessJoinResult;pub use core::ProcessTryJoinResult;pub use core::SchedulerState;pub use core::ThreadLocalState;pub use core::TryJoinResult;pub use core::add_process;pub use core::bootstrap_scheduler;pub use core::exit_thread;pub use core::handle_terminal_exception;pub use core::initialize;pub use core::sleep_until;pub use core::start_thread;pub use core::tick;pub use core::try_deferred_reschedule;pub use core::yield_timeslice;pub use affinity::AffinityMask;pub use affinity::CoreId;pub use algorithm::RescheduleReason;pub use locks::SchedLockGuard;pub use locks::WaitQueueLock;pub use locks::WaitQueueLockGuard;pub use priority::Priority;pub use process::Process;pub use process::ProcessHandle;pub use thread::Stack;pub use thread::StackStorage;pub use thread::StackStorageExt;pub use thread::State;pub use thread::Thread;pub use thread::ThreadArg;pub use thread::ThreadHandle;pub use thread::ThreadState;pub use thread::init_thread_in;pub use timer::TimerQueue;pub use wait_queue::WaitQueue;pub use wait_queue::WaitType;pub use wait_queue::WakeList;pub use wait_queue::WakeResult;