F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
Os::Generic Namespace Reference

Namespaces

 Queue
 

Classes

struct  LocklessAtomicLockFree
 compile-time lock-free possibility for an atomic of unsigned integral width WIDTH More...
 
class  LocklessPriorityQueue
 lockless ISR-safe priority queue implementation for Os::QueueInterface More...
 
struct  LocklessPriorityQueueHandle
 handle for the lockless priority queue More...
 
struct  LocklessSlot
 per-slot data for the lockless priority queue More...
 
class  PriorityMemQueue
 AtomicQueue-based priority queue implementation. More...
 
struct  PriorityMemQueueHandle
 critical data stored for priority queue More...
 
class  PriorityQueue
 generic priority queue implementation More...
 
struct  PriorityQueueHandle
 critical data stored for priority queue More...
 
struct  UsedTotal
 Generic used/total struct. More...
 

Typedefs

using LocklessStateTagType = U64
 

Enumerations

enum  LocklessSlotState : LocklessStateTagType { LOCKLESS_SLOT_FREE = 0, LOCKLESS_SLOT_WRITING = 1, LOCKLESS_SLOT_READY = 2, LOCKLESS_SLOT_READING = 3 }
 slot lifecycle states for the lockless priority queue More...
 
enum  Status { OP_OK, ERROR }
 Generic OK/ERROR status. More...
 

Functions

static constexpr U32 priorityBitMask (FwQueuePriorityType priority)
 Get the bit mask for a priority. More...
 
static I32 findMSB (U32 value)
 Find most significant bit set (IPC-style priority finding) More...
 
static void validateQueueConfigs (PriorityMemQueue::QueueConfig *queueConfigs, FwSizeType numQueueConfigs)
 Validate queue configuration structures. More...
 
static Types::AtomicQueueresolvePriorityQueue (PriorityMemQueueHandle &handle, FwQueuePriorityType &priority, FwEnumStoreType queueId, bool requirePrioritySizing)
 Resolve priority to a valid AtomicQueue, fallback to DEFAULT if needed. More...
 
static void updateHighWaterMark (std::atomic< U32 > *highWaterMarks, FwSizeType index, U32 currentDepth, FwEnumStoreType queueId)
 Update per-priority high water mark atomically. More...
 

Variables

constexpr U32 LOCKLESS_QUEUE_BLOCKING_BACKOFF_US = 100
 
constexpr FwSizeType LOCKLESS_QUEUE_SLOT_ALIGNMENT = 64
 
constexpr FwSizeType LOCKLESS_QUEUE_MAX_RETRY_PASSES = 4
 
constexpr U32 LOOP_GUARD_LIMIT = 2000
 

Typedef Documentation

◆ LocklessStateTagType

Unsigned integral type of the lockless queue slot state-tag word. The low STATE_BITS hold the slot state; the remaining bits hold the ABA epoch tag. std::atomic of this type must be lock-free on the target platform (never-lock-free widths are rejected at compile time; the authoritative check is runtime-asserted at create()). Platforms without lock-free 64-bit atomics may configure a narrower type (U32, U16, or U8), shrinking the ABA tag by the same amount (62, 30, 14, or 6 tag bits respectively; see SDD sections 4 and 15 for the wrap consequence and a WARNING on the narrow-tag ordering risk).

Definition at line 26 of file LocklessQueueCfg.hpp.

Enumeration Type Documentation

◆ LocklessSlotState

slot lifecycle states for the lockless priority queue

Each slot in the queue moves through a four-state state machine. Producers transition slots FREE -> WRITING -> READY. Consumers transition slots READY -> READING -> FREE. State values occupy the low bits of a packed atomic; the remaining bits are used as an ABA tag.

Enumerator
LOCKLESS_SLOT_FREE 

slot contains no data; available to a producer

LOCKLESS_SLOT_WRITING 

producer has reserved the slot and is filling it

LOCKLESS_SLOT_READY 

slot contains a published message available to a consumer

LOCKLESS_SLOT_READING 

consumer has reserved the slot and is draining it

Definition at line 59 of file LocklessPriorityQueue.hpp.

◆ Status

Generic OK/ERROR status.

Enumerator
OP_OK 

Operation succeeded.

ERROR 

Operation failed.

Definition at line 26 of file Os.hpp.

Function Documentation

◆ findMSB()

static I32 Os::Generic::findMSB ( U32  value)
inlinestatic

Find most significant bit set (IPC-style priority finding)

Parameters
valuebit mask to search
Returns
bit position of MSB, or -1 if no bits set

Definition at line 190 of file PriorityMemQueue.cpp.

◆ priorityBitMask()

static constexpr U32 Os::Generic::priorityBitMask ( FwQueuePriorityType  priority)
static

Get the bit mask for a priority.

Parameters
prioritypriority to get mask for
Returns
bit mask with the priority bit set

Definition at line 54 of file PriorityMemQueue.cpp.

◆ resolvePriorityQueue()

static Types::AtomicQueue* Os::Generic::resolvePriorityQueue ( PriorityMemQueueHandle handle,
FwQueuePriorityType priority,
FwEnumStoreType  queueId,
bool  requirePrioritySizing 
)
static

Resolve priority to a valid AtomicQueue, fallback to DEFAULT if needed.

Parameters
handlequeue handle
priorityinput/output priority (may be modified to DEFAULT)
queueIdqueue ID for assertions
requirePrioritySizingwhether to assert on fallback
Returns
pointer to AtomicQueue or nullptr if uninitialized

Definition at line 591 of file PriorityMemQueue.cpp.

◆ updateHighWaterMark()

static void Os::Generic::updateHighWaterMark ( std::atomic< U32 > *  highWaterMarks,
FwSizeType  index,
U32  currentDepth,
FwEnumStoreType  queueId 
)
static

Update per-priority high water mark atomically.

Parameters
highWaterMarksarray of HWM atomics
indexarray index (not priority value)
currentDepthcurrent queue depth
queueIdqueue ID for assertions

Definition at line 621 of file PriorityMemQueue.cpp.

◆ validateQueueConfigs()

static void Os::Generic::validateQueueConfigs ( PriorityMemQueue::QueueConfig queueConfigs,
FwSizeType  numQueueConfigs 
)
static

Validate queue configuration structures.

Parameters
queueConfigsarray of queue configurations to validate
numQueueConfigsnumber of configurations

Definition at line 258 of file PriorityMemQueue.cpp.

Variable Documentation

◆ LOCKLESS_QUEUE_BLOCKING_BACKOFF_US

constexpr U32 Os::Generic::LOCKLESS_QUEUE_BLOCKING_BACKOFF_US = 100

Backoff (microseconds) between bounded scans on the BLOCKING send/receive paths. Shorter values lower message latency; longer values lower idle CPU use of blocked threads. Must be greater than 0: a zero backoff could livelock on a strict-priority scheduler.

Definition at line 31 of file LocklessQueueCfg.hpp.

◆ LOCKLESS_QUEUE_MAX_RETRY_PASSES

constexpr FwSizeType Os::Generic::LOCKLESS_QUEUE_MAX_RETRY_PASSES = 4

Retry passes through the slot array before a NONBLOCKING operation returns FULL/EMPTY. Larger values reduce spurious FULL/EMPTY under contention at the cost of a larger bound on non-blocking call time (depth * passes).

Definition at line 41 of file LocklessQueueCfg.hpp.

◆ LOCKLESS_QUEUE_SLOT_ALIGNMENT

constexpr FwSizeType Os::Generic::LOCKLESS_QUEUE_SLOT_ALIGNMENT = 64

Alignment (bytes) of each queue slot. Set to the target's cache-line size (typically 64) to avoid false sharing between adjacent slots under contention; smaller power-of-two values reduce memory use on constrained targets.

Definition at line 36 of file LocklessQueueCfg.hpp.

◆ LOOP_GUARD_LIMIT

constexpr U32 Os::Generic::LOOP_GUARD_LIMIT = 2000

Definition at line 26 of file PriorityMemQueue.cpp.