Strolling along the sea shore on the sunny day I think I’ve found a
peculiar way of using the Mqueue to the full advantage in my project.
I have a message receiving process which is activated by an IRQ proxy.
The process is the while() loop which begings with mq_recieve(), later on
in the loop, under some conditions, it may decide to mq_send() to the same
queue it is reading from, marking the message with the highest priority.
It exits the while() loop waiting for the next IRQ proxy.
All other senders to the queue are allocated with message priorities less
than the maximum.
And additionally - they are running on a lesser priorities than the
receiver.
Am I guaranteed that on the next execution of the said loop (because of
IRQ proxy) it will mq_receive() the data it had last sent there?
Will it mq_receive() it’s own messages while in the while() loop? (It may
decide to send itself a message more than once.) Does this depend on the
relative priorites of the Mqueue server and the receiving process?
(I see that Mqueue is by default on “10o” priority level, the receiver is
considered to be a driver process and may be somewhere around level 15~19.)
Am I at any risk of the deadlock? May the mq_send() from the while() loop
block because some other sender (though running on a lower priority than
my driver) managed to post a message in the queue making it full again?
Please comment.
Tony.
PS If it really works as I think - it may save me a lot of logic both in
the driver and the senders.
The expected behaviour is to repeat some messages if some conditions were
true. It is also expected to begin the next run with the same (repeated)
message intentionally left (sent by my driver, actually) in the queue from
the last run.
I expect the queue to have a free slot to mq_send() to for my driver
because of the previous mq_receive() there.
May be I should exit the loop if there are no pending messages in the
queue so that mq_receive() never blocks…
Should I reexecute mq_receive() if it returned EINTR? Will I have to merge
the two parts of the INTRupted message?
There is the flow chart here, have a look, please.