Implement domain and endpoint modules with capability management, message passing, and scheduling features

This commit is contained in:
2026-10-17 23:09:21 +02:00
parent 667bc7f7f7
commit 06b51b6712
25 changed files with 1064 additions and 24 deletions

View File

@@ -0,0 +1,52 @@
use super::priority_queue::PriorityQueue;
use types::bounded::Priority;
use types::id::{CoreId, ThreadId};
pub struct PerCoreScheduler {
core: CoreId,
queue: PriorityQueue,
current: Option<ThreadId>,
}
impl PerCoreScheduler {
pub fn new(core: CoreId) -> Self {
Self {
core,
queue: PriorityQueue::new(),
current: None,
}
}
pub fn core(&self) -> CoreId {
self.core
}
pub fn current(&self) -> Option<ThreadId> {
self.current
}
pub fn add(&mut self, thread: ThreadId, priority: Priority) {
self.queue.add(thread, priority);
}
pub fn remove(&mut self, thread: ThreadId, priority: Priority) {
self.queue.remove(thread, priority);
}
pub fn pick_next(&mut self) -> Option<ThreadId> {
let (thread, _priority) = self.queue.next()?;
self.current = Some(thread);
Some(thread)
}
pub fn clear_current(&mut self) {
self.current = None;
}
pub fn len(&self) -> usize {
// for load balancing — count of ready threads
// could track this incrementally instead of computing
// but for now, bitmap popcount works
self.queue.bitmap().count_ones() as usize
}
}