In various examples of waiting on some event (semaphore, queue) I see that someone is using while (very often in sys_arch.c of lwip), i.e.:
while( xSemaphoreTake( *pxSemaphore, portMAX_DELAY ) != pdTRUE );
Is it really necessary? Is it just coding style? What is the reason if portMAX_DELAY macro should wait indefinitely?
A couple of points:
1) A lot of examples we provide use indefinite delays. This is done for
convenience and to ensure the examples are kept as simple as possible.
However, in real applications indefinite delays are rarely a good idea
as they do not provide an opportunity to correct erroneous conditions if
the event being waited for never occurs.
2) ...and in answer to your question...portMAXDELAY is only an
indefinite delay if INCLUDEvTaskSuspend is set to 1. The code snippet
you show probably has INCLUDEvTaskSuspend set to 0, in which case
portMAXDELAY will be a block time of 0xffffffff or 0xffff, depending on
whether configUSE16BIT_TICKS is set to 0 or 1.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.