perf(kernel): kernel static all-zero -> .bss (image 812K -> 173K): domain::Slot (repr(u8) Empty=0) for tables, zero generation counters, core ids by position, pool/platform installed at boot; Option-backed Slot under kani (cbmc speed); build fails if .data > 16K

This commit is contained in:
2026-10-28 13:01:52 +01:00
parent 419b715a1f
commit a2d4a7d085
24 changed files with 320 additions and 116 deletions

View File

@@ -13,14 +13,14 @@ use crate::{error::KernelError, generations::SlotGenerations};
pub const MAX_THREADS: usize = if cfg!(kani) { 3 } else { 256 };
pub struct ThreadTable {
threads: [Option<Thread>; MAX_THREADS],
threads: [crate::slot::Slot<Thread>; MAX_THREADS],
generations: SlotGenerations<MAX_THREADS>,
}
impl ThreadTable {
pub const fn new() -> Self {
Self {
threads: [const { None }; MAX_THREADS],
threads: [const { crate::slot::Slot::Empty }; MAX_THREADS],
generations: SlotGenerations::new(),
}
}
@@ -36,7 +36,7 @@ impl ThreadTable {
self.threads
.iter()
.enumerate()
.position(|(i, t)| t.is_none() && self.generations.is_usable(i))
.position(|(i, t)| !t.is_full() && self.generations.is_usable(i))
}
pub fn spawn(
@@ -52,7 +52,7 @@ impl ThreadTable {
*self
.threads
.get_mut(idx)
.ok_or(KernelError::TooManyThreads)? = Some(Thread::new(
.ok_or(KernelError::TooManyThreads)? = crate::slot::Slot::Full(Thread::new(
id,
process,
priority,
@@ -76,7 +76,7 @@ impl ThreadTable {
*self
.threads
.get_mut(idx)
.ok_or(KernelError::TooManyThreads)? = Some(Thread::with_context(
.ok_or(KernelError::TooManyThreads)? = crate::slot::Slot::Full(Thread::with_context(
id,
process,
priority,