Address nasa#1401 for Linux OS_QueueGet finite timeouts.#1514
Conversation
|
mq_timedreceive_monotonic() is not in the POSIX standard. Per what I found on the Net, it is specific to QNX and not supported on Linux, FreeBSD, or RTEMS. Per the POSIX Issue 8 definition of mqueue.h, message queues do not include a function similar to pthread_mutex_clocklock() which lets you specify the clock. poll() is similar to select() in that there it should not be assumed that it will work on anything other than sockets when dealing with an RTOS TCP/IP stack. |
|
Hi @joelsherrill I apologize. Yes, I will review your feedback and make proper changes to the proposed solution to check if it remains viable. Thank you for your response. I'm changing this PR to draft. |
Since the name looks like POSIX function, you need to at least add the suffix of "_np" for non-portable. But since it is provided outside of the OS and libraries, I'd recommend using another name entirely. What does the implementation of that function depend on? |
Hi Joel. Function is now purely internal and no longer exposed in os-posix.h. It depends on:
The helper is now a I’ll continue testing this PR for further improvements. |
Keep the monotonic timeout repair scoped to the Linux path in the POSIX queue backend. Preserve OS_PEND, OS_CHECK and the non-Linux mq_timedreceive() path. While tightening helper naming, poll()/receive behavior and return-value checking. Also make the queue time-jump regression test Linux-only, privilege- gated, bounded and restore CLOCK_REALTIME during teardown.
bb2865d to
d6c08fe
Compare
…ceive-timeout-if-sysclock-changes # Conflicts: # .gitignore
a01346f to
23bc133
Compare
|
Updated this PR after earlier feedback. The current diff is now limited to:
The implementation is intentionally Linux-only inside the POSIX backend. It relies on Linux-documented polling capacity of mqueue descriptors and does not present that behavior as portable POSIX. The old standard-looking helper/public-prototype direction has been removed. Non-Linux POSIX behavior remains on the existing Local verification:
The regression test is Linux-only, privilege-gated, bounded, and restores |
|
One design-scope question: Is a Linux-scoped repair acceptable for #1401, or should this PR aim for a POSIX-general solution? The current patch relies on Linux-specific I also prototyped a local no-poll, mqueue-preserving alternative that avoids treating That approach avoids I would prefer maintainer guidance before changing the implementation to that direction if needed. |
Update
This description reflects the current branch after addressing earlier review feedback. The earlier implementation shape discussed in older comments has been superseded.
Checklist
Describe the contribution
Addresses #1401 for the Linux path of the POSIX queue implementation.
Non-Linux POSIX behavior remains unchanged, so this is a scoped Linux repair rather than a complete POSIX-wide redesign.
Finite
OS_QueueGet()timeouts now track an internalCLOCK_MONOTONICdeadline on Linux, avoiding timeout extension whenCLOCK_REALTIMEjumps forward or backward.This change is intentionally scoped to Linux inside the POSIX backend. It relies on Linux-documented behavior that POSIX message queue descriptors are pollable file descriptors. This is not presented as portable POSIX behavior.
The current implementation:
src/os/posix/src/os-impl-queues.c.CLOCK_MONOTONICto compute and track the finite timeout deadline.poll()on the Linuxmqd_tdescriptor to wait for queue readiness up to the remaining monotonic time.mq_timedreceive()with an already-expired timeout for the receive step so it cannot block if another reader consumes the message first.mq_timedreceive()path.OS_PENDandOS_CHECKsemantics.Testing performed
Local generic-linux permissive unit-test build:
Result:
Privileged Linux queue regression test:
Result:
Expected behavior changes
OS_QueueGet()waits in the POSIX backend are bounded by monotonic elapsed time instead of wall-clock time.OS_PENDbehavior is unchanged.OS_CHECKbehavior is unchanged.System(s) tested on
Additional context
The regression test is Linux-only and privilege-gated because it uses
clock_settime(CLOCK_REALTIME, ...).The test applies a bounded
CLOCK_REALTIMEjump, verifies finite queue timeout behavior, and restoresCLOCK_REALTIMEduring teardown using the saved realtime value plus elapsed monotonic time.Third party code
None.
Contributor Info - All information REQUIRED for consideration of pull request
Franco Chiesa Docampo - Personal.