Day57 - POSIX Message Queue IPC¶
Date¶
2026-05-18
Topics¶
- POSIX message queue IPC
- mq_open()
- mq_send()
- mq_receive()
- mq_attr
- message priority
- blocking queue
- non-blocking queue
- mq_notify()
- epoll + mqueue
- timerfd integration
- signalfd integration
Implemented¶
Basic POSIX mqueue IPC¶
Implemented:
- independent sender
- independent receiver
- queue creation/open
- blocking receive
- message transmission
Queue Attribute Management¶
Explored:
- mq_maxmsg
- mq_msgsize
- mq_curmsgs
- mq_flags
Observed:
Priority Queue¶
Implemented message priority.
Verified:
- higher priority dequeued first
- FIFO ordering inside same priority
Blocking Queue Behavior¶
Verified:
Non-Blocking Queue¶
Implemented:
Observed:
mq_notify()¶
Implemented:
notification.
Learned:
- empty -> non-empty transition
- one-shot registration
- re-arm logic
- queue drain pattern
epoll Integration¶
Integrated:
- mqueue fd
- timerfd
- signalfd
into one epoll loop.
timerfd¶
Used timerfd for:
- periodic queue statistics
- mq_curmsgs monitoring
signalfd¶
Used signalfd for:
- SIGINT
- SIGTERM
graceful shutdown handling.
Key Learnings¶
POSIX Message Queue¶
Kernel-managed IPC:
- synchronized by kernel
- message-oriented
- priority-aware
Linux Event Architecture¶
Compared:
vs
POSIX vs Linux Style¶
mq_notify()¶
POSIX async notification model.
epoll¶
Linux fd readiness model.
Unified Event Loop¶
Final architecture:
This demonstrates modern Linux userspace middleware architecture.
Result¶
Successfully implemented a complete Linux POSIX message queue IPC demo with:
- blocking/non-blocking operation
- priority queue
- async notification
- epoll integration
- timerfd/signalfd integration
- unified Linux event loop