pub struct PerCore {
pub run_queue: SpinLock<VecDeque<Box<Thread>>>,
pub remain: AtomicIsize,
}Expand description
Per-core scheduler state.
The PerCore struct represents the per-core scheduling state in a
multi-core system. Each CPU core maintains its own scheduling queue to
manage runnable threads independently. This structure is used within the
RoundRobin scheduler to ensure that each core schedules and executes
threads in a fair and efficient manner.
Fields§
§run_queue: SpinLock<VecDeque<Box<Thread>>>Queue of threads ready to run on this CPU core.
- Protected by a
SpinLockto prevent concurrent access issues. - Threads are stored in a [
VecDeque] to allow efficient push/pop operations.
remain: AtomicIsizeRemaining time slice for the currently running thread.
- Uses
AtomicIsizefor safe atomic updates across multiple CPU cores. - Typically decremented on each timer interrupt, triggering a context switch when it reaches zero.
- You can use [``] for load, store to this variable.