Expand description
A no_std
preemptive multithreading library built from scratch for OS kernels and embedded systems.
This library provides preemptive multithreading capabilities without requiring the standard library, making it suitable for embedded systems, OS kernels, and other resource-constrained environments.
§Features
std-shim
: Enable compatibility layer for standard libraryx86_64
: Enable x86_64 architecture supportarm64
: Enable ARM64 architecture supportriscv64
: Enable RISC-V 64-bit architecture supportfull-fpu
: Enable full floating point unit save/restoremmu
: Enable memory management unit features like guard pageswork-stealing
: Enable work-stealing scheduler implementationhardened
: Enable security hardening features
§Architecture
The library is organized around several key abstractions:
- Architecture-specific context switching and interrupt handling
- Pluggable schedulers with different algorithms
- Safe memory management for thread stacks and resources
- Preemptive scheduling with configurable time slices
Re-exports§
pub use arch::Arch;
pub use arch::DefaultArch;
pub use atomic_scheduler::AtomicScheduler;
pub use atomic_scheduler::ATOMIC_SCHEDULER;
pub use error::ThreadError;
pub use error::ThreadResult;
pub use kernel::Kernel;
pub use kernel::SpawnError;
pub use mem::ArcLite;
pub use mem::Stack;
pub use mem::StackPool;
pub use mem::StackSizeClass;
pub use platform_timer::init_preemption_timer;
pub use platform_timer::stop_preemption_timer;
pub use platform_timer::preemption_checkpoint;
pub use safe_api::exit_thread as safe_exit;
pub use safe_api::yield_now;
pub use safe_api::Mutex;
pub use safe_api::MutexGuard;
pub use safe_api::ThreadBuilder as OldThreadBuilder;
pub use safe_api::ThreadHandle;
pub use safe_api::ThreadPool;
pub use scheduler::Scheduler as OldScheduler;
pub use scheduler::SCHEDULER;
pub use stack_guard::ProtectedStack;
pub use stack_guard::StackGuard;
pub use stack_guard::StackStats;
pub use stack_guard::StackStatus;
pub use sync::exit_thread;
pub use sync::yield_thread;
pub use thread::Thread as OldThread;
pub use thread::ThreadState as OldThreadState;
pub use thread_new::Thread;
pub use thread_new::ThreadId;
pub use thread_new::ThreadState;
pub use thread_new::JoinHandle;
pub use thread_new::ThreadBuilder;
pub use thread_new::ReadyRef;
pub use thread_new::RunningRef;
pub use time::Duration;
pub use time::Instant;
pub use time::Timer;
pub use time::TimerConfig;
pub use time::PreemptGuard;
pub use time::IrqGuard;
pub use observability::ThreadMetrics;
pub use observability::SystemMetrics;
pub use observability::ResourceLimiter;
pub use observability::ThreadProfiler;
pub use observability::HealthMonitor;
pub use observability::ObservabilityConfig;
pub use observability::init_observability;
pub use observability::cleanup_observability;
pub use security::SecurityConfig;
pub use security::SecurityViolation;
pub use security::SecurityStats;
pub use security::SecurityFeature;
pub use security::init_security;
pub use security::get_security_stats;
pub use security::configure_security_feature;
pub use sched::Scheduler as NewScheduler;
pub use sched::CpuId;
pub use sched::RoundRobinScheduler;
pub use sched::DefaultScheduler;
Modules§
- arch
- Architecture abstraction layer for context switching and interrupt handling.
- atomic_
scheduler - context
- context_
full - error
- errors
- Comprehensive error handling for the threading system.
- kernel
- Kernel abstraction for managing the threading system.
- mem
- Memory management abstractions for thread safety.
- observability
- Observability and monitoring for the threading system.
- perf
- Performance optimization infrastructure and implementations.
- platform_
timer - Platform-specific timer implementations for preemptive scheduling
- preemption
- safe_
api - sched
- New scheduler implementations with lock-free data structures.
- scheduler
- security
- Security and hardening features for the threading system.
- signal_
safe - stack_
guard - sync
- thread
- thread_
new - New thread abstraction with RAII and memory safety.
- time
- Time management and timer interrupt handling.
Macros§
- assert_
valid_ cas_ ordering - Assert that memory orderings are valid for compare-exchange operations.
- assert_
valid_ load_ ordering - Assert that a memory ordering is valid for load operations.
- assert_
valid_ store_ ordering - Assert that a memory ordering is valid for store operations.
- cfi_
protected_ call - Macro for CFI-protected function calls.
- cross_
domain_ access - Macro for safe cross-domain access.
- isolated_
thread - Macro for creating isolated thread domain.
- preemption_
point - Cooperative preemption points - insert these in long-running code
- protected_
stack - Stack allocation with automatic guard setup
- record_
fence - Convenience macro for recording memory fences.
- record_
read - Convenience macro for recording memory reads.
- record_
write - Convenience macro for recording memory writes.
- return_
address_ guard - Macro for return address protection.
- stack_
canary_ guard - Macro to automatically check stack canaries.