Can xQueueReceive Fail When xTicksToWait = portMAX_DELAY?

Let's imagine I have this kind of event loop :

MyType_t object;
while(true) {
    xQueueReceive(QHandle, &object, portMAX_DELAY);
    doSomething(object);
}

The documentation () stipulates :

If INCLUDE_vTaskSuspend is set to ‘1’ then specifying the block time as portMAX_DELAY will cause the task to block indefinitely (without a timeout).

To me, this means that it will always wait until it can receive a value, which means it can never fail to receive a value, but I may be wrong.

Is it necessary to check for xQueueReceive failure ? If it is, what are the failure modes ?

3

1 Answer

Suspending a task allows truly indefinite blocking on a queue. Otherwise it returns with timeout after portMAX_DELAY ticks which is usually very, very long. If the slightly increased code size setting INCLUDE_vTaskSuspend to 1 doesn’t matter I’d propose to do so. Although receiving from a queue with indefinite timeout can’t fail it’s good style to check the return code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Sarah Jenkins

Sarah Jenkins

Senior Technology Editor & AI Specialist

Sarah Jenkins is a veteran tech journalist with over 12 years of experience covering artificial intelligence, mobile innovations, and digital ethics. Her insights have appeared in leading technology publications worldwide.

Share this article
Twitter Facebook Pinterest