Page 1 of 1

OS_WaitMsgQ() question

PostPosted: Tue Nov 01, 2011 12:57 pm
by ral613
If I wait on a message queue using OS_WaitMsgQ() with a timeout, what happens if the timeout expires, but a message then arrives on the queue before the waiting task gets a chance to execute? Does the waiting task see a timeout and invalid message pointer, does it get the message with no timeout, or something else?

Thanks.

Re: OS_WaitMsgQ() question

PostPosted: Thu Nov 03, 2011 7:58 am
by Andrew
Once a timeout occurs, all bets are off as to the ststud of the message -- therefore it is undefined, and is most in keeping with "Does the waiting task see a timeout and invalid message pointer."

Re: OS_WaitMsgQ() question

PostPosted: Thu Nov 03, 2011 8:23 am
by ral613
OK thanks. What I am seeing is a timeout with a null message pointer, and then if I wait on the Q a second time I return right away with the message that was sent after the original timeout expired but before the waiting task got a chance to run.

I was interested in whether this was as designed, i.e. whether I could count on this behaviour. (Not the null pointer, but getting the message in response to the second Q wait.) Looks like I can.