ruvix-queue
io_uring-style ring buffer IPC for the RuVix Cognition Kernel (ADR-087).
Overview
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:
┌─────────────────────────────────────────────────┐
│ KernelQueue │
├────────────────────┬────────────────────────────┤
│ Submission (SQ) │ Completion (CQ) │
│ ┌──┬──┬──┬──┬──┐ │ ┌──┬──┬──┬──┬──┐ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ └──┴──┴──┴──┴──┘ │ └──┴──┴──┴──┴──┘ │
│ head→ ←tail │ head→ ←tail │
└────────────────────┴────────────────────────────┘
Key Features
| Feature | Description |
|---|---|
| Lock-free | Using atomic head/tail pointers |
| Zero-copy | Descriptors point to shared regions |
| Typed | WIT schema validation at send time |
| Priority | Higher priority messages delivered first |
Components
KernelQueue
Main queue implementation:
use ;
use MsgPriority;
// Create a queue with 64 entries and 4KB max message
let config = new;
let mut queue = new?;
// Send a message
queue.send?;
// Receive with timeout
let mut buf = ;
let len = queue.recv?;
RingBuffer
Lock-free ring buffer with atomic operations:
use ;
let mut ring = new;
// Push entry
ring.push?;
// Pop entry
let entry = ring.pop?;
// Check stats
println!;
MessageDescriptor
Zero-copy message passing:
use MessageDescriptor;
// Descriptor points to data in a shared region
let descriptor = MessageDescriptor ;
// Send descriptor instead of copying
queue.send_descriptor?;
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 (ADR-087 Section 20.5): Only Immutable or AppendOnly regions can use descriptors. The kernel rejects descriptors pointing into Slab regions to prevent time-of-check-to-time-of-use attacks.
Priority Levels
use MsgPriority;
// Four priority levels
let critical = Critical; // Sensor alerts
let high = High; // Control messages
let normal = Normal; // Data messages
let low = Low; // Background tasks
Statistics
use RingStats;
let stats = queue.stats;
println!;
println!;
println!;
Features
std(default): Enable standard library supportalloc: Enable alloc crate support
Integration with RuVix
This crate integrates with:
ruvix-types: Core type definitions (QueueHandle,MsgPriority)ruvix-cap: Capability checking for queue accessruvix-region: Region handles for zero-copy descriptors
License
MIT OR Apache-2.0