Skip to main content

CpuArch

Trait CpuArch 

Source
pub trait CpuArch {
    // Required methods
    fn current_core_id() -> usize;
    fn max_cores() -> usize;
    fn spinlock_acquire(lock: &LockWord);
    fn spinlock_release(lock: &LockWord);
    fn send_ipi(target_core: usize);
    fn supports_smp() -> bool;
}
Expand description

The per-architecture primitives a multi-core kernel needs — and nothing else.

Implemented for RISC-V, ARM (A/R profile), Xtensa, the hosted backends, and a single-core fallback for targets that cannot support SMP.

Required Methods§

Source

fn current_core_id() -> usize

Which physical core is executing this code, 0-based.

Source

fn max_cores() -> usize

How many cores the chip has. Validates KernelConfig::active_cores before anything is brought up.

Source

fn spinlock_acquire(lock: &LockWord)

Take the interlock. Local interrupts are already masked by SpinLock.

Source

fn spinlock_release(lock: &LockWord)

Release the interlock.

Source

fn send_ipi(target_core: usize)

Ask another core to reschedule (target_core is a core id, not a mask).

Source

fn supports_smp() -> bool

Whether more than one core can run concurrently on this target.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl CpuArch for HostArch

Available on crate feature std only.