The EMBODIOS kernel is a bare-metal AI operating system kernel that runs AI models directly on hardware without traditional OS overhead.
The kernel is structured into several key components:
- Boot System: Multiboot2-compliant bootloader for x86_64, UEFI support for ARM64
- Memory Management:
- Physical Memory Manager (PMM) using buddy allocator
- Virtual Memory Manager (VMM) with 4-level paging
- Slab allocator for kernel heap management
- Task Scheduler: RTOS-style priority scheduler with deadline support and priority inheritance
- CPU Management: Feature detection, SIMD support for AI workloads
- Console I/O: VGA text mode (x86_64), UART (ARM64)
0x0000000000000000 - 0x00007FFFFFFFFFFF: User space0xFFFFFFFF80000000 - 0xFFFFFFFF80100000: Kernel image (1MB)0xFFFFFFFF80100000 - 0xFFFFFFFF90000000: Kernel heap (256MB)0xFFFFFFFF90000000 - 0xFFFFFFFFA0000000: VMM heap (256MB)
0x0000000000000000 - 0x0000FFFFFFFFFFFF: User space (48-bit)0xFFFF000000000000 - 0xFFFF000000200000: Kernel image (2MB)0xFFFF000000200000 - 0xFFFF000010000000: Kernel heap
The kernel implements an RTOS-style priority scheduler designed for mixed-criticality workloads, enabling safety-critical AI inference to preempt lower-priority tasks.
- Priority Levels: 0-31 (0 = highest priority, 31 = lowest)
- Preemptive: High-priority tasks immediately preempt lower-priority tasks
- Round-Robin: Tasks with equal priority use round-robin scheduling (10-tick time quantum)
- Timer-Based: Preemption occurs on timer interrupts (10ms tick rate)
- Tasks can specify absolute deadlines (in timer ticks)
- Deadline-aware scheduling automatically boosts priority for tasks approaching deadlines (<10 ticks)
- Missed deadlines are logged for debugging and analysis
- Deadline of 0 means no deadline constraint
Prevents unbounded priority inversion in mixed-criticality systems:
- When a high-priority task blocks on a resource held by a low-priority task, the low-priority task inherits the high priority
- Transitive inheritance: priority propagates through blocking chains (A waits for B waits for C)
- Priority is restored to original level when the resource is released
- Priority inversions are detected and logged with task details
// Task creation with priority
task_t* task_create(const char *name, task_func_t entry, void *arg, uint8_t priority);
// Priority management
void task_set_priority(task_t *task, uint8_t priority);
uint8_t task_get_priority(task_t *task);
// Deadline management
void task_set_deadline(task_t *task, uint64_t deadline_ticks);
uint64_t task_get_deadline(task_t *task);
// Preemption control (for critical sections)
void scheduler_disable_preemption(void);
void scheduler_enable_preemption(void);
// Priority inheritance (used internally by synchronization primitives)
void task_inherit_priority(task_t *from, task_t *to);
void task_restore_priority(task_t *task);- Safety-Critical Inference: High-priority tasks for real-time control decisions (e.g., collision detection in robotics)
- Background Processing: Lower-priority tasks for model training or data logging
- Time-Bounded Operations: Deadline support for guaranteeing inference completion times
- Mixed Workloads: Run multiple AI models with different criticality levels on a single system
The scheduler tracks key metrics:
- Context switches: Total number of task switches
- Preemptions: Number of times high-priority tasks preempted running tasks
- Priority inversions: Number of detected priority inversion events
- Access via
scheduler_stats()for debugging and performance analysis
- GCC cross-compiler for target architecture
- GNU Make
- GRUB2 (for x86_64 ISO creation)
# Build for x86_64 (default)
make
# Build for ARM64
make ARCH=arm64
# Create bootable ISO (x86_64 only)
make iso
# Clean build artifacts
make clean- ✅ Multiboot2 boot protocol (x86_64)
- ✅ 64-bit long mode initialization
- ✅ Physical memory management (buddy allocator)
- ✅ Virtual memory management (4-level paging)
- ✅ Kernel heap allocator (slab allocator)
- ✅ Basic console output
- ✅ CPU feature detection
- ✅ Kernel panic handler
- ✅ RTOS-style priority scheduler (0-31 priority levels)
- ✅ Deadline-aware scheduling with automatic priority boosting
- ✅ Priority inheritance protocol (prevents priority inversion)
- ✅ Preemptive multitasking with timer-based preemption
- 🔄 Interrupt handling (IDT/GDT for x86_64, GIC for ARM64)
- 🔄 Model runtime integration
- 🔄 Command processor
- ⏳ Network stack
- ⏳ Persistent storage
- ⏳ Multi-core support
- ⏳ Power management
The kernel can embed AI model weights directly in the binary:
- Model weights are included via assembly in the
.model_weightssection - Weights are loaded from
_model_weights_startto_model_weights_end - The model runtime provides inference capabilities in pure C
- Create header in
include/embodios/ - Implement in appropriate subdirectory
- Add to Makefile sources
- Update architecture-specific code if needed
Currently, the kernel can be tested using:
- QEMU for x86_64:
qemu-system-x86_64 -kernel embodios.elf - QEMU for ARM64:
qemu-system-aarch64 -M virt -cpu cortex-a72 -kernel embodios.bin
See LICENSE file in the repository root.