feat(kernel): add handle_tick and handle_interrupt entry points

This commit is contained in:
2026-10-18 00:17:55 +02:00
parent 74b296a2bf
commit 95c023f286
4 changed files with 146 additions and 5 deletions

View File

@@ -152,4 +152,41 @@ impl<P: Platform> Kernel<P> {
let cap = Capability::new(resource, permissions, Generation::initial());
self.processes.get_mut(to)?.capabilities_mut().insert(cap)
}
#[cfg(test)]
pub fn spawn_thread_for_test(
&mut self,
pid: ProcessId,
priority: Priority,
time_slice: TimeSlice,
) -> ThreadId {
use domain::scheduler::Scheduler;
let tid = self.threads.spawn(pid, priority, time_slice, None).expect("spawn");
let _ = self.processes.get_mut(pid).map(|p| p.add_thread(tid));
let core = self.platform.core_id();
self.scheduler.add(tid, priority, core);
tid
}
#[cfg(test)]
pub fn register_irq_for_test(&mut self, irq: types::id::IrqId, thread: ThreadId) {
let _ = self.irqs.register(irq, thread);
}
#[cfg(test)]
pub fn block_thread_for_test(
&mut self,
tid: ThreadId,
reason: domain::thread::BlockReason,
) {
use domain::scheduler::Scheduler;
let core = self.platform.core_id();
if let Ok(t) = self.threads.get_mut(tid) {
if matches!(t.state(), ThreadState::Ready) {
let _ = t.set_running(core);
}
let _ = t.block(reason);
}
self.scheduler.remove(tid);
}
}