⚠️ VeridianOS Kernel Documentation - This is low-level kernel code. All functions are unsafe unless explicitly marked otherwise. no_std

Module lockfree_queue

Module lockfree_queue 

Source
Expand description

Lock-Free MPSC Queue

A wait-free multi-producer, single-consumer queue using atomic operations. Designed for the scheduler ready queue where multiple CPUs may enqueue tasks concurrently while only the owning CPU dequeues.

Implementation uses a Michael-Scott style linked list with AtomicPtr:

  • Enqueue: CAS on tail pointer (lock-free, linearizable)
  • Dequeue: CAS on head pointer (lock-free, single consumer)
  • Memory reclamation via hazard pointers

This queue is cache-line padded to avoid false sharing between the head and tail pointers on different CPUs.

Structs§

LockFreeQueue
A lock-free multi-producer, single-consumer queue.