Skip to content

sptos-queue

io_uring-style ring buffer IPC for SPTOS Cognition Kernel

Overview

sptos-queue implements the Queue primitive from ADR-087. All inter-task communication in SPTOS goes through queues -- there are no synchronous IPC calls, no shared memory without explicit region grants, and no signals. Queues use io_uring-style ring buffers with separate submission and completion queues.

Key Features

  • Lock-free ring buffers — Atomic head/tail pointers for concurrent access without locks
  • Zero-copy semantics — Descriptor-based transfer when sender and receiver share a region
  • Priority messaging — Higher priority messages are delivered first
  • TOCTOU protection — Only Immutable or AppendOnly regions can use zero-copy descriptors
  • Optimized variantOptimizedRingBuffer for performance-critical paths

Dependencies

Key internal dependencies:

  • sptos-types — Queue types (QueueHandle, QueueConfig, MsgPriority)
  • sptos-region — Memory region backing for queue storage

Usage

rust
use sptos_queue::{KernelQueue, QueueConfig};
use sptos_types::MsgPriority;

let config = QueueConfig::new(64, 4096);
let mut queue = KernelQueue::new(config, region_handle)?;

queue.send(b"hello", MsgPriority::Normal)?;
let msg = queue.recv(&mut buf, timeout)?;

API Reference

Core Types

TypeDescription
KernelQueueFull-featured queue with send/recv and priority support
RingBufferCore lock-free ring buffer implementation
RingEntrySingle entry in a ring buffer slot
MessageDescriptorZero-copy descriptor referencing data in a shared region
PrioritizedDescriptorDescriptor with attached priority for ordered delivery
DescriptorValidatorValidates descriptors against region policies
OptimizedRingBufferPerformance-optimized ring buffer variant
ReceivedMessageMessage received from a queue with metadata

Released under the MIT License.