The POSIX message queue functions mq_timedreceive() and mq_timedsend() are limited to CLOCK_REALTIME for their timeout parameter.
This repository provides two wrapper functions: mq_timedreceive_monotonic() and mq_timedsend_monotonic(), which use CLOCK_MONOTONIC instead.
The implementation is based primarily on poll().
This repository also includes an integration test that demonstrates the difference between:
mq_timedreceive()usingCLOCK_REALTIMEmq_timedreceive_monotonic()usingCLOCK_MONOTONIC
The test changes the Linux system wall clock while both modes are waiting, showing that:
- the
mq_timedreceive()timeout is affected by wall-clock changes - the
mq_timedreceive_monotonic()timeout remains stable
See tests/integration/README.md for details about what the test verifies and how to run it.