Skip to main content

Module mailbox

Module mailbox 

Source
Expand description

N1 IntrusiveMailbox : lock-free LIFO mailbox for kernel-internal IPC.

This is a stack (LIFO) structure, not a FIFO queue. Messages are inserted at the head and popped from the head. This is acceptable for notification-style IPC between trusted kernel components (scheduler <==> VFS, scheduler <==> memory manager) where message ordering is not critical.

For FIFO-guaranteed IPC, use the [LockFreeRing] (N2) instead.

ยงSafety

The mailbox uses tagged pointers (x86-64 canonical addresses) for ABA-safe lock-free push/pop. See tag_ptr and untag_ptr.

Structsยง

IntrusiveMailbox
MailboxMessage
A single message node in the intrusive linked list.
NodePool ๐Ÿ”’
A lock-free LIFO mailbox (stack) for kernel-internal IPC.

Enumsยง

MailboxError
Errors from mailbox operations.

Constantsยง

FREELIST_CAPACITY ๐Ÿ”’
Default number of pre-allocated node slots in the freelist. Chosen to cover the maximum expected number of in-flight N1 messages.
POOL_GEN_SHIFT ๐Ÿ”’
Shift for the generation counter in a tagged pool pointer.
POOL_PTR_MASK ๐Ÿ”’
Mask for the pointer portion of a tagged pool pointer.
PTR_MASK ๐Ÿ”’
TAG_MASK ๐Ÿ”’
TAG_SHIFT ๐Ÿ”’

Staticsยง

TAG_COUNTER ๐Ÿ”’

Functionsยง

tag_ptr ๐Ÿ”’
Encode a wrapped tag into the upper bits of a pointer value.
untag_ptr ๐Ÿ”’
Strip the tag and recover the real pointer.