§ kernel

Architecture

Layered, monolithic, Rust-bounded — the shape of the kernel.

axiomOS is a monolithic kernel structured as layered subsystems with Rust trait boundaries. Microkernel IPC at the control-loop layer would cost hundreds of nanoseconds per message — unacceptable for the latencies we target. Trait boundaries give us the modularity of a microkernel without the address-space crossings.

Layers

LayerResponsibility
UserspaceELF binaries, standard syscall ABI
Process / Task managerPer-process address spaces, work-stealing tasks, fd tables
SubsystemseBPF runtime, VFS, network, IPC
Memory + InterruptsFrame allocator, per-process VM, interrupt routing
HALtrait Architecture { ... }, x86_64, aarch64, riscv64
HardwareCPUs, RAM, GPIO, timers, peripherals

Process vs task

Traditional UNIX conflates the resource container (process) with the execution context (thread). axiomOS separates them:

struct Process {
    pid: ProcessId,
    name: String,
    address_space: RwLock<Option<AddressSpace>>,
    file_descriptors: RwLock<BTreeMap<FdNum, FileDescriptor>>,
}

struct Task {
    tid: TaskId,
    process: Arc<Process>,
    last_stack_ptr: Pin<Box<usize>>,
    kstack: Option<HigherHalfStack>,
    ustack: RwLock<Option<LowerHalfAllocation<Writable>>>,
}

This simplifies multithreading (multiple tasks per process), resource accounting (per-process, not per-thread), and memory isolation (tasks within a process share an address space).

Scheduling

The current implementation uses a single global MPSC queue across all CPUs. Preemption is driven by timer interrupts on a configurable quantum (1 ms by default). Cooperation is via sched_yield(). Priority inheritance is planned.

Syscall path

1. Userspace executes syscall instruction
2. CPU switches to kernel mode → arch handler
3. Context saved (registers, stack pointer)
4. Syscall number dispatched
   ├─→ BPF pre-hook runs (if attached)
   ├─→ Syscall handler executes
   └─→ BPF post-hook runs (if attached)
5. Return value written to register
6. Context restored → return to userspace

Negative return values follow the -errno convention.