Hello @gedare @JoelSherrill,
I am currently studying the codebase and relevant documentation to understand the “Lower Message Priority Range Supported by POSIX Message Queues” issue for my GSoC '26 proposal.
Over the last few days, I have been tracing coremsginsert.c, coremsgsubmit.c, coremsgimpl.h, and chainimpl.h, and cross-referencing them with the POSIX and RTEMS API documentation:
- POSIX Message Passing Manager: 17. Message Passing Manager — RTEMS POSIX API Guide 7.1023b8c (8th January 2026) documentation
- Open Group
mq_send/mq_timedsendspec: mq_send - Open Group
<mqueue.h>header spec: ]<mqueue.h> - POSIX
limits.hview showing_POSIX_MQ_PRIO_MAX= 32:
limits.h(0p) - Linux manual page
This confirms that the fixed limit is inserted by the toolchain during compilation and aligns strictly with POSIX standards.
From there, I traced the current O(n) linear scan bottleneck caused by the ordered chain insertion in coremsginsert.c.
its in chainimpl.h
The while loop is iterating to every node, making it O(n).
I also took time to verify the existing test cases. Initially, I planned to write a separate test file (psxmsgq05) to validate these boundaries. However, after reviewing psxmsgq01, I realized it already covers these scenarios. I ran psxmsgq01 locally and verified it successfully checks all edge cases:
- Priorities >
MQ_PRIO_MAXare correctly rejected. - Inter-priority insertion (Strict priority ordering, which is currently O(n)).
- Intra-priority insertion (FIFO ordering for messages with the exact same priority).
The goal of my proposal will be to design a more efficient insertion algorithm. One suggestion I saw was to use a Red-Black tree, and I am also exploring other optimal solutions like fixed priority buckets that leverage the bounded MQ_PRIO_MAX limit.
Clearly greater than
MQ_PRIO_MAX is not accepted, the time complexity reduction can produce a significant impact.
I look forward to contributing more and would welcome any general advice or feedback on this issue!


