Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT




Loading

waiting portMAX_DELAY

Posted by rrrum on May 23, 2016

Hello,

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?

rum


waiting portMAX_DELAY

Posted by rtel on May 23, 2016

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.


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS