- badges + Mint, Call/Reply/ReplyRecv w/ gen-checked reply slot - cap transfer (1/msg, copy, needs Delegate, rechecked at delivery) - notifications: signal/wait/poll/bind, irq -> notification routing - WaitAny/WaitForInterrupt removed; a0=status, ErrorCode - libkos: single ecall primitive, compat wrappers + typed new api - fix: trap return clobbered user t0 on every trap - fix: wait queues FIFO, delegate keeps badge, fault cap checked - docs/ipc.md spec, ipc tests, ipc fuzz, kani ntfn + waitqueue
57 lines
1.8 KiB
Rust
57 lines
1.8 KiB
Rust
use domain::scheduler::{Scheduler, SchedulerDecision};
|
|
use platform::Platform;
|
|
use types::id::CoreId;
|
|
|
|
use crate::Kernel;
|
|
|
|
impl<P: Platform> Kernel<P> {
|
|
pub fn handle_tick(&mut self, core: CoreId) -> SchedulerDecision {
|
|
let current_tid = match self.scheduler.current(core) {
|
|
Some(tid) => tid,
|
|
None => return SchedulerDecision::Continue,
|
|
};
|
|
|
|
let thread = match self.threads.get_mut(current_tid) {
|
|
Ok(t) => t,
|
|
Err(_) => return SchedulerDecision::Continue,
|
|
};
|
|
|
|
let expired = thread.time_slice_mut().tick();
|
|
if expired {
|
|
thread.time_slice_mut().reset();
|
|
let priority = thread.priority();
|
|
if thread.preempt().is_err() {
|
|
return SchedulerDecision::Continue;
|
|
}
|
|
self.scheduler.add(current_tid, priority, core);
|
|
match self.scheduler.next(core) {
|
|
Some(next) => {
|
|
if self
|
|
.threads
|
|
.get_mut(next)
|
|
.and_then(|t| t.set_running(core))
|
|
.is_ok()
|
|
{
|
|
SchedulerDecision::Preempt(next)
|
|
} else {
|
|
let _ = self
|
|
.threads
|
|
.get_mut(current_tid)
|
|
.map(|t| t.set_running(core));
|
|
SchedulerDecision::Continue
|
|
}
|
|
}
|
|
None => {
|
|
let _ = self
|
|
.threads
|
|
.get_mut(current_tid)
|
|
.map(|t| t.set_running(core));
|
|
SchedulerDecision::Continue
|
|
}
|
|
}
|
|
} else {
|
|
self.scheduler.tick(core, current_tid)
|
|
}
|
|
}
|
|
}
|