pub struct Kernel<A: Arch, S: Scheduler> { /* private fields */ }
Expand description
Main kernel handle that manages the threading system.
This struct coordinates all threading operations and provides a safe interface to the underlying scheduler and architecture abstractions.
§Type Parameters
A
- Architecture implementationS
- Scheduler implementation
Implementations§
Source§impl<A: Arch, S: Scheduler> Kernel<A, S>
impl<A: Arch, S: Scheduler> Kernel<A, S>
Sourcepub fn init(&self) -> Result<(), ()>
pub fn init(&self) -> Result<(), ()>
Initialize the kernel.
This must be called before any threading operations can be performed. It sets up architecture-specific features and prepares the scheduler.
§Returns
Ok(())
if initialization succeeds, Err(())
if already initialized.
Sourcepub fn is_initialized(&self) -> bool
pub fn is_initialized(&self) -> bool
Check if the kernel has been initialized.
Sourcepub fn next_thread_id(&self) -> ThreadId
pub fn next_thread_id(&self) -> ThreadId
Generate a new unique thread ID.
Thread IDs are never reused and are guaranteed to be unique for the lifetime of the kernel instance.
Sourcepub fn spawn<F>(
&self,
entry_point: F,
priority: u8,
) -> Result<JoinHandle, SpawnError>
pub fn spawn<F>( &self, entry_point: F, priority: u8, ) -> Result<JoinHandle, SpawnError>
Sourcepub unsafe fn handle_timer_interrupt(&self)
pub unsafe fn handle_timer_interrupt(&self)
Handle a timer interrupt for preemptive scheduling.
This should be called from the architecture-specific timer interrupt handler.
§Safety
Must be called from an interrupt context.
Sourcepub fn thread_stats(&self) -> (usize, usize, usize)
pub fn thread_stats(&self) -> (usize, usize, usize)
Get current thread statistics.