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
A lock-free LIFO mailbox (stack) for kernel-internal IPC.
MailboxMessage
A single message node in the intrusive linked list.

Enumsยง

MailboxError
Errors from mailbox operations.

Constantsยง

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.