preemptive-threads
A #![no_std]
preemptive multithreading library for Rust.
Features
- No standard library - Built for embedded systems and OS kernels
- Preemptive scheduling - Timer-based thread preemption (Linux)
- Priority scheduling - Higher priority threads run first
- x86_64 only - Hand-written assembly for fast context switching
- Static allocation - No heap required, deterministic memory usage
Installation
[]
= "0.1.0"
Usage
use ;
static mut STACK1: = ;
static mut STACK2: = ;
Preemptive Scheduling (Linux only)
use Preemption;
static mut PREEMPTION: Preemption = new;
unsafe
Requirements
- Architecture: x86_64 only
- OS: Any (preemption requires Linux)
- Memory: ~64KB per thread (configurable)
- Threads: Maximum 32 concurrent threads
Safety
This is a low-level library that requires unsafe
code:
- Direct memory management for thread stacks
- Context switching modifies CPU state
- Shared scheduler access needs synchronization
License
MIT OR Apache-2.0