Expand description
io_uring-style Ring Buffer IPC for RuVix Cognition Kernel.
This crate implements the Queue primitive from ADR-087 Section 7. All inter-task communication in RuVix goes through queues. There are no synchronous IPC calls, no shared memory without explicit region grants, and no signals.
§Architecture
Queues use io_uring-style ring buffers with separate submission (SQ) and completion (CQ) queues. This enables:
- Lock-free operation: Using atomic head/tail pointers
- Zero-copy semantics: When sender and receiver share a region
- Typed messages: WIT schema validation at send time
- Priority support: Higher priority messages are delivered first
§Zero-Copy Semantics
When sender and receiver share a region, queue_send places a descriptor
(offset + length) in the ring rather than copying bytes. This is critical
for high-throughput vector streaming where copying 768-dimensional f32
vectors would be prohibitive.
TOCTOU Protection: Only Immutable or AppendOnly regions can use descriptors (ADR-087 Section 20.5). The kernel rejects descriptors pointing into Slab regions to prevent time-of-check-to-time-of-use attacks.
§Example
use ruvix_queue::{KernelQueue, QueueConfig};
use ruvix_types::MsgPriority;
// Create a queue
let config = QueueConfig::new(64, 4096); // 64 entries, 4KB max message
let mut queue = KernelQueue::new(config, region_handle)?;
// Send a message
queue.send(b"hello", MsgPriority::Normal)?;
// Receive with timeout
let mut buf = [0u8; 4096];
let len = queue.recv(&mut buf, Duration::from_millis(100))?;Structs§
- Descriptor
Validator - Validator for message descriptors.
- Kernel
Queue - A kernel queue for inter-task communication.
- Message
Descriptor - A zero-copy message descriptor.
- Optimized
Ring Buffer - Optimized lock-free ring buffer with power-of-2 size.
- Optimized
Ring Entry - Optimized ring entry header (8 bytes).
- Optimized
Ring Slot - Cache-line aligned ring slot.
- Queue
Config - Configuration for a kernel queue.
- Ring
Buffer - A lock-free ring buffer for message passing.
- Ring
Entry - A lock-free ring buffer entry.
- Ring
Stats - Statistics for ring buffer operations.